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) 12 days ago. Updated 5 days ago.

Status:
Closed
Target version:
-
[ruby-core:125124]

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) 12 days ago Actions #1

  • Description updated (diff)

Updated by ioquatix (Samuel Williams) 12 days ago Actions #2

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

Updated by ioquatix (Samuel Williams) 12 days 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) 12 days 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) 12 days 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 11 days ago Actions #6

  • Status changed from Open to Closed

Applied in changeset git|7c8762a93f7083566ee6695368da1487fa35fd4e.


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

[Bug #21964]

Updated by ioquatix (Samuel Williams) 10 days ago Actions #7

  • Backport changed from 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED to 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED

Updated by rwstauner (Randy Stauner) 5 days ago Actions #8

  • Backport changed from 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED to 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE
Actions

Also available in: PDF Atom