Skip to content

Thread#kill behind Thread#raise: no tests for the delivered-and-rescued, retracted and fiber-wait paths #143

Closed

Description

@Largo

#127 queues a Thread#kill that arrives behind a parked Thread#raise and promotes it once the raise is dealt with (_killsBehindRaise in Src/Ruby/Runtime/RubyUtils.cs). Thread_KillBehindRaise1 covers only one of the ways that happens. In each of its parts, a Thread.handle_interrupt(RuntimeError => :never) mask holds the raise back, and the kill is promoted at the next safe point inside the mask (CheckAsyncException, then PromoteKillBehindRaise).

Paths with no test (CodeRabbit's review of #127):

  • The raise is delivered and the thread rescues it. The kill then has to be parked and end the thread (UnparkLocked from GetPendingAsyncException).
  • The raise is withdrawn (RetractAsyncException). The waiting kill has to be parked then.
  • A fiber waiting for control (the killOnly promotion in the fiber-switch wait).

The hard part is determinism: the raise and the kill must both be parked before the thread reaches a safe point, and the raise must then be delivered unmasked. Options: a test-only hook in the runtime that holds a thread at a known point, or a C# test in IronRuby.Tests that parks both exceptions directly through RubyUtils before releasing the thread.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions