arton/rjb

Crash when using puma forking

bmulholland opened this issue · 3 comments

I posted a repro here: https://github.com/bmulholland/rjb-fork-crash

Short version is that, when trying to use puma workers, Rjb.load crashes. Output is:

objc[10802]: +[NSMethodSignature initialize] may have been in progress in another thread when fork() was called.
objc[10802]: +[NSMethodSignature initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
arton commented

Hi bmulholland
I couldn't reproduce it on my X64 Linux. I suppose it causes JVM implementation for ARM. Any other Java application runs fine ?
By the way, thank you for giving me the reproducable project. It' very helpful (sorry not for this case).

We have reproduced this crash (or at least, one very similar) on an Intel Mac as well. A workaround for us is to run the Rjb.load on every HTTP request, inside the worker. That workaround runs on all our machines, so there's no problem with JVM or anything. We do, however, need to use OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES for it to work, which seems dangerous, but at least it's only necessary on our development machines.

To add to @bmulholland 's comment, here's the configuration added to puma.rb:

before_fork do
  Rjb.load # Remove all the Rjb.load calls in the app
end