Project

General

Profile

Actions

Bug #21964

closed

Fiber stack acquire can expand unnecessarily

Bug #21964: Fiber stack acquire can expand unnecessarily

Added by ioquatix (Samuel Williams) 1 day ago. Updated about 6 hours ago.


Description

In several common scenarios, the fiber stack allocator can choose to expand the fiber stack pool even when there are unreachable (effectively dead) fibers.

For example, the following program will eventually crash if GC does not run in time:

loop do
  Fiber.new{Fiber.yield}.resume
end

We have a loop that resumes a fiber, that fiber yields, and then becomes unreachable. Eventually, we will exhaust the OS vm map limit and fail with FiberError. However, at most only one fiber (stack) is needed to execute the above program, since the fiber immediately becomes unreachable.

To fix this, we need to run GC on expansion failure: https://github.com/ruby/ruby/pull/16535.

Updated by ioquatix (Samuel Williams) 1 day ago Actions #1

  • Description updated (diff)

Updated by ioquatix (Samuel Williams) 1 day ago Actions #2

  • Subject changed from Fiber stack acquire can expand unnecessarily. to Fiber stack acquire can expand unnecessarily

Updated by ioquatix (Samuel Williams) 1 day ago Actions #3

  • Subject changed from Fiber stack acquire can expand unnecessarily to Fiber stack acquire can expand unnecessarily, causing unexpected `FiberError`

Updated by ioquatix (Samuel Williams) 1 day ago Actions #4 [ruby-core:125126]

It's worth noting that this is similar to how it's currently handled in io.c: https://github.com/ruby/ruby/blob/4eab86efde9c98e8f51caeb95a0cf25acd7958f6/io.c#L1077-L1085

Updated by ioquatix (Samuel Williams) 1 day ago Actions #5

  • Subject changed from Fiber stack acquire can expand unnecessarily, causing unexpected `FiberError` to Fiber stack acquire can expand unnecessarily
  • Description updated (diff)

Updated by Anonymous about 6 hours ago Actions #6

  • Status changed from Open to Closed

Applied in changeset git|7c8762a93f7083566ee6695368da1487fa35fd4e.


Run GC if fiber pool expansion fails. (#16535)

[Bug #21964]

Actions

Also available in: PDF Atom