We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
It's possible for the TaskGroup.run call to terminate before all the tasks in the group have completed.
TaskGroup.run
Repro:
require 'workers' # test.rb Signal.trap("USR1") do puts "RECEIVED SIGNAL" end group = Workers::TaskGroup.new group.add { sleep(10000000) } puts group.run puts group.tasks[0].state
In one shell: ruby test.rb
ruby test.rb
In another shell, run:
$ ps aux | grep test.rb jlfwong 42699 0.0 0.1 2511824 14252 s004 S+ 2:16PM 0:00.36 ruby test.rb $ kill -30
Then switching back to the original shell, I see the following:
RECEIVED SIGNAL false running
My expectation in this case would be that run would just not terminate until much much later.
run
After 10000000 seconds, I'd expect the output to be:
RECEIVED SIGNAL true succeeded
From digging around in ruby source, it seems to me that ConditionVariable::wait is not signal safe. http://ruby-doc.org/stdlib-2.0.0/libdoc/thread/rdoc/ConditionVariable.html
ConditionVariable::wait
::wait calls mutex.sleep, which in turn calls rb_mutex_sleep, which eventually ends up doing this: https://github.com/ruby/ruby/blob/55f93cb63f350c7705733f86923561363a297e00/thread.c#L1084
::wait
mutex.sleep
rb_mutex_sleep
Which will exit as soon as the native_sleep call terminates, which is I believe upon receiving any handled signal.
native_sleep
I arrived here trying to debug why running my code under stackprof was causing failures (commentary on this issue here: tmm1/stackprof#91 (comment))
stackprof
The text was updated successfully, but these errors were encountered:
No branches or pull requests
It's possible for the
TaskGroup.run
call to terminate before all the tasks in the group have completed.Repro:
In one shell:
ruby test.rb
In another shell, run:
Then switching back to the original shell, I see the following:
My expectation in this case would be that
run
would just not terminate until much much later.After 10000000 seconds, I'd expect the output to be:
From digging around in ruby source, it seems to me that
ConditionVariable::wait
is not signal safe. http://ruby-doc.org/stdlib-2.0.0/libdoc/thread/rdoc/ConditionVariable.html::wait
callsmutex.sleep
, which in turn callsrb_mutex_sleep
, which eventually ends up doing this: https://github.com/ruby/ruby/blob/55f93cb63f350c7705733f86923561363a297e00/thread.c#L1084Which will exit as soon as the
native_sleep
call terminates, which is I believe upon receiving any handled signal.I arrived here trying to debug why running my code under
stackprof
was causing failures (commentary on this issue here: tmm1/stackprof#91 (comment))The text was updated successfully, but these errors were encountered: