Skip to content

Interpreter segfault when resuming fiber from nilable ivar #16210

@ysbaddaden

Description

@ysbaddaden

I identified the interpreter segfault from #16128 and #16209 and the following example reproduces: the interpreter segfaults when the scheduler tries to resume the fiber:

class Foo
  property fiber : Fiber?

  def enqueue
    @fiber.not_nil!("oops").enqueue
    # ^-- the scheduler segfaults when resuming the fiber
  end
end

foo = Foo.new
foo.fiber = Fiber.new { p "hello world" }
foo.enqueue

Fiber.yield

For the record, using a local variable works around the issue:

  def enqueue
    if fiber = @fiber
      fiber.enqueue
      # ^-- this is fine
    else
      raise NilAssertionError.new("oops")
    end
  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions