Conversation

Replying to and
My preferred solution to that problem is deprecating fork and treating nontrivial use of fork as the nasty detail rest of program has to tiptoe around, but languages that chose to expose fork rejected that. 😣
1
1
Replying to and
So I think where the problem is really hard to assign blame/responsibility for fixing is where a program in an affected language (Ruby?) uses fork and indirectly uses a module with FFI to a C library using threads they weren't even aware of.
1
1
Replying to and
It's a very common issue but the race condition often has a very low chance of happening in practice, so it mostly goes unnoticed. Users will notice that applications sometimes fail to start or perform an operation but it's hard for them to figure out what could be causing that.
1
2
Replying to and
Even with malloc, applications often don't trigger the race condition regularly. In our experience some cases only happen 1/20 times, etc. Android uses a fork-based spawning model by default and they had to make everything used by the app runtime work, but not beyond that.
1
1
What we dislike about the Zygote spawning model existing is that it makes it easy for them to implement optimizations simply by loading libraries and doing initialization in the Zygote. Since they only run the code once per architecture during boot, it's not as heavily optimized.
1
They explicitly do a bunch of preloading work to run a bunch of initialization needed by nearly every app in the Zygote: android.googlesource.com/platform/frame It saves a lot of time, especially on lower-end devices. It also saves a lot of memory by reusing loaded resources, relocations, etc.
On the positive side, since they now officially support wrappers as a development tool in production releases, they keep exec-based spawning working upstream... but their implementation is ridiculously slow, and we lack the time to deal with more than the lowest hanging fruit.