-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix(main/ruby): fix fork
panicking
#23611
base: master
Are you sure you want to change the base?
Conversation
mbekkomo
commented
Mar 5, 2025
- Closes [Bug]: ruby 3.4.1 fork broken #23582
@csabahenk Could you test this after the build is done? |
It's interesting progress, but for me, this makes the error change from
to
|
This is one way to work around it I guess if there is no other way to be found, The change in ruby that caused the error to start appearing is this: ruby/ruby@63cbe3f Since the problem bisects to that commit, reverting it like this would cause the error to stop: Reverts https://github.com/ruby/ruby/commit/63cbe3f6ac9feb44a2e43b1f853e2ca7e049316c
which makes https://github.com/termux/termux-packages/issues/23582 go back to previous behavior (working)
--- a/ext/socket/raddrinfo.c
+++ b/ext/socket/raddrinfo.c
@@ -342,7 +342,7 @@ rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hint
arg.service = portp;
arg.hints = hints;
arg.res = ai;
- return (int)(VALUE)rb_thread_call_without_gvl(fork_safe_getaddrinfo, &arg, RUBY_UBF_IO, 0);
+ return (int)(VALUE)rb_thread_call_without_gvl(nogvl_getaddrinfo, &arg, RUBY_UBF_IO, 0);
}
#elif GETADDRINFO_IMPL == 2
@@ -505,7 +505,7 @@ start:
}
pthread_t th;
- if (raddrinfo_pthread_create(&th, fork_safe_do_getaddrinfo, arg) != 0) {
+ if (raddrinfo_pthread_create(&th, do_getaddrinfo, arg) != 0) {
int err = errno;
free_getaddrinfo_arg(arg);
errno = err;
--- a/process.c
+++ b/process.c
@@ -4233,23 +4233,12 @@ rb_fork_ruby(int *status)
prefork();
before_fork_ruby();
- rb_thread_acquire_fork_lock();
disable_child_handler_before_fork(&old);
child.pid = pid = rb_fork();
child.error = err = errno;
disable_child_handler_fork_parent(&old); /* yes, bad name */
- if (
-#if defined(__FreeBSD__)
- pid != 0 &&
-#endif
- true) {
- rb_thread_release_fork_lock();
- }
- if (pid == 0) {
- rb_thread_reset_fork_lock();
- }
after_fork_ruby(pid);
/* repeat while fork failed but retryable */
however, what the ruby creators are trying to do is make the language more thread-safe, so by completely reverting their change, this still does not "fully solve" the problem because it misses out on their feature, by continuing to use the old, less-thread-safe behavior that the old version of ruby was using. I think an ideal solution would probably be one that can properly fix the fork lock feature in a thread-safe way that does not have |
@mbekkomo alas, wiith ruby 3.4.1-1, ruby still panics, although in different function with a different errno.
|
It's better to check the Ruby Issue Tracker, we might find something useful there to solve this problem. |
fork
panicking on EPERMfork
panicking because of thread deadlock
fork
panicking because of thread deadlockfork
panicking
@robertkirkman @csabahenk Can you try the latest commit build? |
I've tried the latest build myself and met with |