Project

General

Profile

Actions

Bug #17875

closed

Segfault when reusing a closed Fiber scheduler inside a Thread

Added by rmosolgo (Robert Mosolgo) 3 months ago. Updated about 2 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:103923]

Description

Hi! I've been trying to learn the new Fiber.scheduler API. I ran into this segfault when I was misusing scheduler instances in Minitest. I was able to reproduce the bug in isolation and I thought I'd share it here in case it's helpful to anyone.

I attached the program as scheduler_bug.rb and the output in bug_output.txt. I expected this program to terminate with an error, but not with a segfault.

If there's anything else I can do to help, please let me know! Thanks,

Robert


Files

scheduler_bug.rb (4.92 KB) scheduler_bug.rb rmosolgo (Robert Mosolgo), 05/20/2021 08:10 PM
bug_output.txt (24.1 KB) bug_output.txt rmosolgo (Robert Mosolgo), 05/20/2021 08:10 PM

Updated by xtkoba (Tee KOBAYASHI) 3 months ago

The symptom seems similar to that of #17618.

Updated by rmosolgo (Robert Mosolgo) 3 months ago

Ah, yes, thanks for linking back to that. It sure looks like the same thing. I searched for "fiber scheduler segfault" and didn't find it, but I see it calls it "segv" instead.

Please feel free to close this one if it's not useful (I'm not sure if it's useful or not).

Updated by xtkoba (Tee KOBAYASHI) 3 months ago

Seems already fixed?

$ ruby scheduler_bug.rb
#<Thread:0x00007f933e4f7760 scheduler_bug.rb:240 run> terminated with exception (report_on_exception is true):
scheduler_bug.rb:241:in `block in <main>': undefined method `run' for nil:NilClass (NoMethodError)
scheduler_bug.rb:114:in `ensure in close': undefined method `each' for nil:NilClass (NoMethodError)
        from scheduler_bug.rb:120:in `close'
scheduler_bug.rb:110:in `close': Scheduler already closed! (RuntimeError)
scheduler_bug.rb:241:in `block in <main>': undefined method `run' for nil:NilClass (NoMethodError)
scheduler_bug.rb:241:in `block in <main>': undefined method `run' for nil:NilClass (NoMethodError)

$ ruby -v
ruby 3.1.0dev (2021-05-04T15:46:40Z master 14c932e52d) [x86_64-linux]
  built with x86_64-pc-linux-gnu-gcc (Gentoo 11.1.0 p1) 11.1.0

Not the same as #17618, which still segfaults without the PR merged. (I have confirmed that the attached code segfaults with Ruby 3.0.1p64 on x86_64-linux.)

Updated by rmosolgo (Robert Mosolgo) 3 months ago

Oh, thanks! I installed 3.1.0-dev and it worked fine for me, too. (That is, it failed with a nice error message and backtrace.) I thought I was on the latest version, but I guess I overlooked the -dev version.

I can't figure out how to close this issue ... could someone help me close it (or close it for me) please?

Actions #5

Updated by jeremyevans0 (Jeremy Evans) about 2 months ago

  • Status changed from Open to Closed
Actions

Also available in: Atom PDF