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
andelasticsearch
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:
- [__NSCFConstantString initialize] may have been in progress in another thread when fork() was called rails/rails#38560
- Mac fork() fatal error rails/spring#606
- Segmentation fault ged/ruby-pg#538
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
Labels
No labels