Skip to content
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

Segmentation fault with array of Fibers #3230

Closed
dalarenal opened this issue Oct 26, 2016 · 0 comments
Closed

Segmentation fault with array of Fibers #3230

dalarenal opened this issue Oct 26, 2016 · 0 comments

Comments

@dalarenal
Copy link

fibers = []
counter = 0

loop do
  fibers << Fiber.new do
    loop do
      Fiber.yield
    end
  end

  fibers.each do |fiber|
    fiber.resume
    fibers.delete(fiber)
  end

  counter += 1
  puts "ends of loop ##{counter}"
end

The previous snippet is causing a segmentation fault using the last compiled version of mrbuy (commit: c45ed46) on Linux (Ubuntu 16.04) and MacOS (10.11.6)

...
ends of loop #1310
ends of loop #1311
ends of loop #1312
ends of loop #1313
ends of loop #1314
ends of loop #1315
ends of loop #1316
ends of loop #1317
ends of loop #1318
ends of loop #1319
ends of loop #1320
ends of loop #1321
ends of loop #1322
ends of loop #1323
[1]    12903 segmentation fault (core dumped)  bin/mruby ../failure.rb

but is working fine (without any segmentation fault) using mruby 1.2.0 (version tagged as 1.2.0)

It's also working disabling the garbage collector, with the following code:

GC.disable

fibers = []
counter = 0

loop do
  fibers << Fiber.new do
    loop do
      Fiber.yield
    end
  end

  fibers.each do |fiber|
    fiber.resume
    fibers.delete(fiber)
  end

  counter += 1
  puts "ends of loop ##{counter}"
end

I think is a garbage collector problem. I would like to know what is causing this, and if is possible to know how to fix it.

@matz matz closed this as completed in 9a12627 Oct 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant