spring
spring copied to clipboard
Mac fork() fatal error
I suddenly starting running into an issue today on my Rails project where all commands I run that use spring as a preloader, such as rspec or rake fail due to an error similar to this:
objc[8689]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
objc[8689]: +[__NSCFConstantString 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.
This happened right after I upgraded all my Homebrew packages on my Mac machine (Mac OS 10.15.1). I can verify that I was not running into this issue on my machine before I upgraded my Homebrew packages, which rules out the issue being due to an application code change. I can also note that I have deduced this to be a Spring issue because I don't run into this error when I run these commands with Spring disabled, via the DISABLE_SPRING=1 variable.
I'm guessing that one of the upgrades from one of my Homebrew packages is serving as a catalyist for this bug to manifest. I'm unsure of how to track this down myself. Here's my list of Homebrew packages, maybe it'll be useful.
In the meanwhile, I'm using an environment variable workaround I've commonly seen in Google searches, such as from this post, to disable this MacOS check.
Having the same issue 😕
I checked your Hombrew packages against mine and these are the ones we both have:
automake
dep
direnv
exercism
gnupg
htop
libtool
neovim
overmind
postgresql
rsync
This appears to be causing me issues as well. Any attempts to connect to Postgres hit a segfault due to some spring incompatibility with something. Of the Homebrew packages already listed, I share:
automake
gnupg
htop
libtool
postgresql
rsync
Further information from reporting the issue to the Ruby bug tracker, in case it was a problem deeper in Ruby, it appears to potentially be related to an interaction between spring, Postgres 12, and the pg gem. Their response can be found here: https://bugs.ruby-lang.org/issues/16390
FYI: I tried downgrading to postgresql11 and the issue persisted
I'm also using pg11
Might be related to this cause of segfaults in the pg gem, though I haven't verified: https://github.com/ged/ruby-pg/issues/311
Is this related? https://blog.phusion.nl/2017/10/13/why-ruby-app-servers-break-on-macos-high-sierra-and-what-can-be-done-about-it/
Re-installing PostgreSQL fixed the issue for me. Check https://github.com/ged/ruby-pg/issues/311#issuecomment-576837101
Remains an issue for us. When running spring we can randomly get one of two errors. Big Sur, both M1 and different errors on Intel. Concur that all signs point to forking, pg, maybe postgis for us. I've re-installed everything, tried the environment variables on various threads etc, nothing. Should note that identical setup on Linux has no problems.
I can hand off crash logs, the fault, and crash as needed, just ping me.
We're seeing this issue still today:
Environment:
- Mac OS 12.0.1
- Rails 6.1.3.1,
- Ruby 3.0.1,
- Postgres 14 (via Postgress.app)
We've opted to remove Spring as was crashing too much for us.
Recently it's broken again due to https://github.com/ged/ruby-pg/issues/538#issuecomment-1591629049