spring icon indicating copy to clipboard operation
spring copied to clipboard

Mac fork() fatal error

Open ecbrodie opened this issue 6 years ago • 13 comments

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.

ecbrodie avatar Nov 25 '19 20:11 ecbrodie

Having the same issue 😕

pcriv avatar Nov 27 '19 08:11 pcriv

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

pcriv avatar Nov 27 '19 08:11 pcriv

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

CodingAnarchy avatar Dec 02 '19 17:12 CodingAnarchy

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

CodingAnarchy avatar Dec 02 '19 19:12 CodingAnarchy

So the issue is either on:

  • The pg gem
  • libpq
  • Something else...

pcriv avatar Dec 02 '19 20:12 pcriv

FYI: I tried downgrading to postgresql11 and the issue persisted

pcriv avatar Dec 02 '19 20:12 pcriv

I'm also using pg11

jpaas avatar Dec 02 '19 21:12 jpaas

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

CodingAnarchy avatar Dec 16 '19 19:12 CodingAnarchy

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/

ric2b avatar Dec 27 '19 18:12 ric2b

Re-installing PostgreSQL fixed the issue for me. Check https://github.com/ged/ruby-pg/issues/311#issuecomment-576837101

pcriv avatar Jan 24 '20 08:01 pcriv

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.

mjy avatar Aug 25 '21 22:08 mjy

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.

jonathansimmons avatar Mar 02 '22 21:03 jonathansimmons

Recently it's broken again due to https://github.com/ged/ruby-pg/issues/538#issuecomment-1591629049

berniechiu avatar Jun 16 '23 09:06 berniechiu