Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGABRT on OSX 10.12 (Sierra) after fork() #195

Closed
onyxraven opened this issue Sep 26, 2016 · 21 comments
Closed

SIGABRT on OSX 10.12 (Sierra) after fork() #195

onyxraven opened this issue Sep 26, 2016 · 21 comments

Comments

@onyxraven
Copy link

onyxraven commented Sep 26, 2016

Crash Log and DiagnosticReport: https://gist.github.com/onyxraven/ce190bc4c9f31db07ec3c27578d33641

When running rspec via spring, ruby almost immediately crashes with the attached crash info. This is within my rails app, but I can try to get a simpler example put together later today.

What it looks like is the libsqlite3.dylib bundled with Sierra may not be safe for use across a fork.

There is a similar report on the python list https://bugs.python.org/issue27126, and someone else added a bug to the ruby bug list https://bugs.ruby-lang.org/issues/12781.

I've attempted to get the gem to use a different version (eg, the one in Homebrew), but so far I've failed to get it to load anything but the version out of /usr/lib/ - If I can get that workaround figured out, it would get me past this issue for the short term.

If ruby is not forking (eg, via SPRING_DISABLE, or other non-forking code), the sqlite3 code still works fine.

@kumasento
Copy link

I'm facing the same issue.

@Yanchek99
Copy link

Same here causing seg faults.

@markwpiper
Copy link

+1

@rhutch117
Copy link

same issue

@markwpiper
Copy link

Was able to workaround it by installing the sqlite3 gem and forcing it to use the newer version of sqlite from my homebrew installation:

gem uninstall sqlite3
gem install sqlite3 -- --with-sqlite3-include=/usr/local/Cellar/sqlite/3.14.2_1/include --with-sqlite3-lib=/usr/local/Cellar/sqlite/3.14.2_1/lib

@electrickite
Copy link

Also experiencing this issue on macOS Sierra, specifically with v1.3.11. Seems to occur when running a Rails console under spring or using rake to start Resque workers.

In some cases, I can avoid the segfault by setting the environment variable DISABLE_SPRING=1

@jdongelmans
Copy link

Also having this issue.
Thanks @markwpiper for the workaround!

@ccasabona
Copy link

Thanks to markwpiper for a working fix!

@tenderlove
Copy link
Member

Thanks for reporting this. Seems like we're in the same boat as the Python folks. I'd prefer not to embed SQLite3 but maybe we can ship a version that looks for SQLite3 in homebrew before trying to use the system library. Does this seem reasonable to everyone?

In the mean time, you can shorten @markwpiper's workaround to:

gem install sqlite3 -- --with-sqlite3-dir=/usr/local/Cellar/sqlite/3.14.2_1

@excid3
Copy link

excid3 commented Oct 8, 2016

Seems like a reasonable solution to me.

@tenderlove
Copy link
Member

I just pushed 1.3.12. It contains c7226ba, which should fix this problem. You can verify the installed version is linked against homebrew's installed version of SQLite3 by doing otool -L $(gem which sqlite3/sqlite3_native.bundle). The output should look something like this:

[aaron@TC pkg (master)]$ otool -L $(gem which sqlite3/sqlite3_native.bundle)
/Users/aaron/.rbenv/versions/ruby-trunk/lib/ruby/gems/2.4.0/gems/sqlite3-1.3.12/lib/sqlite3/sqlite3_native.bundle:
    /usr/local/opt/sqlite/lib/libsqlite3.0.dylib (compatibility version 9.0.0, current version 9.6.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
    /usr/local/opt/gperftools/lib/libprofiler.0.dylib (compatibility version 5.0.0, current version 5.8.0)
[aaron@TC pkg (master)]$

The important line is where it says /usr/local/opt/sqlite/lib/libsqlite3.0.dylib, which is from homebrew.

I close this if someone can verify the new version fixes the issue. Thank you!

@excid3
Copy link

excid3 commented Oct 9, 2016

@tenderlove Just tested it, can confirm 1.3.12 works great! 🤘

○ otool -L $(gem which sqlite3/sqlite3_native.bundle)
/Users/chris/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.12/lib/sqlite3/sqlite3_native.bundle:
    /usr/local/opt/sqlite/lib/libsqlite3.0.dylib (compatibility version 9.0.0, current version 9.6.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)
    /usr/local/opt/gmp/lib/libgmp.10.dylib (compatibility version 14.0.0, current version 14.1.0)
    /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)

@tenderlove
Copy link
Member

@excid3 great! Thank you for testing. I'll close this ticket now. 😄

@ccasabona
Copy link

I upgraded the version and the fix is working perfectly. Thank you.

Charlie

On Oct 8, 2016, at 10:01 PM, Aaron Patterson notifications@github.com wrote:

@excid3 https://github.com/excid3 great! Thank you for testing. I'll close this ticket now. 😄


You are receiving this because you commented.
Reply to this email directly, view it on GitHub #195 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/AGE6Iol9zelSY-rjze_pSjGMFTW-vGh_ks5qyEr7gaJpZM4KGtDL.

@spikex
Copy link

spikex commented Oct 9, 2016

Worked for me as well. Thanks!

inz added a commit to sealuzh/cloud-stove that referenced this issue Oct 13, 2016
The `libsqlite3.dylib` is apparently not safe for use in forked processes. The updated gem now prefers the homebrew sqlite3.

For further details, see sparklemotion/sqlite3-ruby#195
@synth
Copy link

synth commented Nov 4, 2016

This did not work for me running spork with ruby v1.9.3-p547. I uninstalled the gem, uninstalled the brew, and reinstalled both following the above directions.

UPDATE: I've upgraded app to use spring and still same issue. The otool command returns the proper sqlite dylib path. I've tried fixing this six ways to Sunday, so any help in figuring this out would be most appreciated!

mrhead added a commit to mrhead/action_cable_chat_app that referenced this issue Nov 24, 2016
Previous version crashing when spring was used.

sparklemotion/sqlite3-ruby#195
mrhead added a commit to mrhead/action_cable_chat_app that referenced this issue Nov 24, 2016
Previous version was crashing ruby on macOS Sierra when spring was used.

sparklemotion/sqlite3-ruby#195
@jakeonrails
Copy link

I'm still having this issue.

I've tried:

gem install sqlite3 -- --with-sqlite3-dir=/usr/local/Cellar/sqlite/3.14.2_1

I've reinstalled Ruby 2.2.5 via rvm reinstall 2.2.5

I've manually uninstalled sqlite3 and reinstalled

I've uninstalled sqlite from brew and reinstalled

I've tried brew link --force sqlite

I'm running sqlite3 1.3.12.

My otool output:

otool -L $(gem which sqlite3/sqlite3_native.bundle)
/Users/jakemoffatt/.rvm/gems/ruby-2.2.5/gems/sqlite3-1.3.12/lib/sqlite3/sqlite3_native.bundle:
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.8)
	/usr/local/opt/sqlite/lib/libsqlite3.0.dylib (compatibility version 9.0.0, current version 9.6.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)

Is the problem that the /usr/lib/libz version is shown first? How do I fix that?

My specific error message, migrating a brand new Rails 5 app:

$ rake db:migrate
Running via Spring preloader in process 69525
/Users/jakemoffatt/.rvm/gems/ruby-2.2.5/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:27: [BUG] Segmentation fault at 0x00000000000110
ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-darwin16]

@ascarter
Copy link

ascarter commented Dec 3, 2016

I think I'm hitting it as well even using Homebrew sqlite3:

$ otool -L $(gem which sqlite3/sqlite3_native.bundle)
/Users/andrew/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/sqlite3-1.3.12/lib/sqlite3/sqlite3_native.bundle:
	/opt/homebrew/opt/sqlite/lib/libsqlite3.0.dylib (compatibility version 9.0.0, current version 9.6.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)

Running tests suites on the depot iteration b1 (pragprog Agile Web Development with Rails 5):

bin/rails test
Running via Spring preloader in process 11300
/Users/andrew/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:27: [BUG] Segmentation fault at 0x00000000000110
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]

Installed sqlite3 from homebrew:

$ brew info sqlite
sqlite: stable 3.15.2 (bottled) [keg-only]
Command-line interface for SQLite
https://sqlite.org/
/opt/homebrew/Cellar/sqlite/3.15.2 (11 files, 2.9M)
  Poured from bottle on 2016-12-02 at 20:50:18

Tried:

gem install sqlite3
gem install sqlite3 -- --with-sqlite3-dir=/opt/homebrew/Cellar/sqlite/3.15.2

@ccasabona
Copy link

ccasabona commented Dec 6, 2016 via email

@arthurnn
Copy link

arthurnn commented Jan 4, 2017

I think brew info wasn't working for me, which 427b15e fixed the issue. However that is not released yet. Can you cut another release @tenderlove ?
this is my output after a install of 1.3.12:

[arthurnn@snowball activerecord]$ otool -L $(gem which sqlite3/sqlite3_native.bundle)
/Users/arthurnn/.gem/ruby/2.4.0/gems/sqlite3-1.3.12/lib/sqlite3/sqlite3_native.bundle:
/usr/lib/libsqlite3.dylib (compatibility version 9.0.0, current version 253.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)
/usr/local/opt/gmp/lib/libgmp.10.dylib (compatibility version 14.0.0, current version 14.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)

[arthurnn@snowball activerecord]$ brew --prefix sqlite3
/usr/local/opt/sqlite

For now, I am using this as a solution:

 gem install sqlite3 -- --with-sqlite3-dir=$(brew --prefix sqlite3)

@tenderlove
Copy link
Member

@arthurnn 1.3.13 should be shipped now!

pixeltrix added a commit to rails/rails that referenced this issue Mar 4, 2017
Version 1.3.13 includes the proper fix for the segfaults reported
in sparklemotion/sqlite3-ruby#195.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests