Comments (10)
I think it's not just spring -- I'm starting to see this in my dev environment. I can't quite pin it down, might be something in sidekiq.
from ethon.
Thanks, this helped me understand what's going on.
Won't be a solution for all, but seeing as Rails 7 is dropping Spring by default, some people might be glad to hear it should work when disabling Spring. I reproduced the problem in bin/rails c
and it worked when I used DISABLE_SPRING=1 bin/rails c
instead.
from ethon.
This also happens when running a Puma web server in clustered mode (forked worker processes). I have isolated the problem to this:
easy = Ethon::Easy.new(url: "http://example.com")
handle = easy.handle
fork { Ethon::Curl.easy_perform(handle) }
objc[20103]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
objc[20103]: +[__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.FATAL: prematurely zombied
So the error occurs inside curl_easy_perform
C function.
from ethon.
May be caused by FFI? Couldn't reproduce the error in C.
#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>
#include <curl/curl.h>
int main(void)
{
pid_t pid = fork();
if(pid == 0) {
CURL *curl;
CURLcode res;
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://api.ipify.org");
res = curl_easy_perform(curl);
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
curl_easy_cleanup(curl);
}
curl_global_cleanup();
} else {
waitpid(pid, NULL, 0);
}
return 0;
}
from ethon.
I think it's not just spring -- I'm starting to see this in my dev environment. I can't quite pin it down, might be something in sidekiq.
Yes, it's not just Spring - it's anything that uses fork
while also having already spawned threads. For example Puma's clustered mode, Sidekiq Enterprise' swarm (multi-process) feature, etc…
from ethon.
@stevenharman That article is from 2017, and references an issue in Ruby that was fixed all the way back in Ruby 2.4. I'm guessing this is now something else?
from ethon.
If you're on an M1, this seems to work: typhoeus/typhoeus#687 (comment)
from ethon.
Better solution than hacking around the issue with ENV flags, is to call Ethon::Curl.init
before the application forks (such as in a Rails initializer), since as of Curl v8.2.0, macOS specific calls were moved into the global init.
from ethon.
I tried just calling
Ethon::Curl.init
prior to the fork, which didn't resolve the issue.
This now works as of Curl v8.2.0 unless I'm mistaken, I believe the issue was fixed in this commit.
from ethon.
I can no longer reproduce the crash myself.
from ethon.
Related Issues (20)
- Memory leak in Ethon::Easy HOT 14
- Ruby 3.1.0-dev warning: Exception in finalizer
- Seg Fault on Ubuntu 20.04 Arm64 HOT 4
- JRuby failure with 0.15.0 - NoMethodError: undefined method `bitmask' HOT 1
- Frozen at ETHON: Libcurl initialized HOT 3
- Segfault on autopointer.rb:175 HOT 4
- Can I use curl --resolve?
- Non-blocking IO support with Ruby 3.x fiber scheduler HOT 1
- Easy perform returns `url_malformat` for valid URLs HOT 1
- Custom libcurl.so
- 0.16.0 changelog HOT 1
- http2 example doesn't work: syntax error, unexpected local variable or method, expecting ')' multi.add(easy) HOT 1
- 0.16.0 broke a test in typhoeus
- Ruby-win64 support with libcurl-x64.dll HOT 3
- When Following Redirects `on_headers` Only Emits On First Response
- easy_codes mismatch at 60 HOT 2
- segmentation fault at operations.rb:30 HOT 1
- [BUG] Segmentation fault at ethon-0.16.0/lib/ethon/easy/operations.rb:30 HOT 13
- url_malformat with all request HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ethon.