You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nil assertion failed (Exception)
from src/class.cr:148:0 in 'not_nil!'
from spec/std/signal_spec.cr:0:23 in '->'
from src/signal.cr:255:3 in '->'
from src/signal.cr:255:3 in 'process'
from src/signal.cr:198:9 in '->'
from src/fiber.cr:255:3 in 'run'
from src/fiber.cr:29:34 in '->'
from ???
FATAL: uncaught exception while processing handler for CHLD, exiting
It seems to be a race condition in the Singal::CHLD handler and happens very rarely.
I' might have seen this error more often, but here are at least two instances where it failed in unrelated CI runs:
it "CHLD.trap is called after default Crystal child handler"do
called =false
child =nilSignal::CHLD.trap do
called =trueProcess.exists?(child.not_nil!.pid).should be_false
end
child =Process.new("true", shell:true)
child.not_nil!.wait # doesn't block forever
called.should be_true
end
TIL I learned about SIGCHLD: it's trapped when a child process ends.
The spec fails because of a not_nil! (the trace isn't entirely correct with the filenames and line numbers). But my guess was that child.not_nil! is raising. How could that happen?
Well, if Process.new("true", shell: true) runs and ends before it gets assigned to child, which is super rare, then the handler will be invoked and child will still be nil⚠️
This race condition can be reproduced if you change the child assignment to:
Now to fix it. I guess if child is nil I'll just Fiber.yield until child gets a non-nil value. It's a bit hard fixing this because something happens before an expression gets assigned to a variable 🤔
It seems to be a race condition in the
Singal::CHLD
handler and happens very rarely.I' might have seen this error more often, but here are at least two instances where it failed in unrelated CI runs:
The text was updated successfully, but these errors were encountered: