Skip to content

Segfault when using elasticsearch within spring on MacOS 14.1.1 #2244

Open

Description

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions