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

Segfault when using elasticsearch within spring on MacOS 14.1.1 #2244

Open
dvandersluis opened this issue Nov 16, 2023 · 4 comments
Open

Segfault when using elasticsearch within spring on MacOS 14.1.1 #2244

dvandersluis opened this issue Nov 16, 2023 · 4 comments

Comments

@dvandersluis
Copy link

dvandersluis commented Nov 16, 2023

Describe the bug/error/problem
If an elasticsearch command is run within spring, the process segfaults with the following error:

objc[20558]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
objc[20558]: +[__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.

To Reproduce
Steps to reproduce the behavior:

  • Have Elasticsearch running on localhost:9200 on a newer version of MacOS
  • Create a minimal rails application with spring and elasticsearch in the Gemfile
  • Run bundle install
  • Run rails console
  • Enter the following in the REPL:
    client = Elasticsearch::Client.new
    client.ping
  • The process will segfault with the above error.

Expected behavior
Using elasticsearch within the Rails console should not segfault.

Your Environment (please complete the following information):

  • Operating System: MacOS 14.1.1 (23B81)
  • Ruby Version: ruby 3.1.4p223
  • Elasticsearch client version: 7.12.0, also tried 8.11.0
  • Elasticsearch version: 7.3.2
  • Any other relevant information

Additional context

This is likely related to a lot of other issues such as:

An older article may be relevant too: https://blog.phusion.nl/2017/10/13/why-ruby-app-servers-break-on-macos-high-sierra-and-what-can-be-done-about-it/

Adding export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES in .bash_profile is often given as a workaround but it's unclear that this is a safe workaround and not just a bandaid.

@picandocodigo
Copy link
Member

Thanks for reporting this @dvandersluis.
Unfortunately I don't have a machine with MacOS to test this at the moment. As you pointed out, this seems related to other issues, apparently with how MacOS handles threads and I don't know if there's much we can do on our side about it. It looks like most users have had luck on those GitHub issues with export PGGSSENCMODE="disable", and also this workaround seems to be a better solution. This only occurs when when bundling elasticsearch with rails, right?

@stanhu
Copy link

stanhu commented Jan 8, 2024

I think this might actually be a different issue: curl/curl#11252

Are you using Typhoeus? You could disable that for now and use a different HTTP adapter. Full investigation in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/122412#note_1416939251.

@stanhu
Copy link

stanhu commented Jan 8, 2024

It's possible updating curl may be sufficient as discussed in tarantool/tarantool#8828.

@stanhu
Copy link

stanhu commented Jan 8, 2024

I should note that I had to insert a Ethon::Curl.init in the initializer--before the fork--to ensure that curl's global init function is called.

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

3 participants