Skip to content

Timeout::ExitException can be raised by nested timeouts  #52

Description

@trogd0r

Behavior

Nested timeout blocks can result in a Timeout::ExitException being raised, rather than a Timeout::Error

How to reproduce

The below will sometimes raise a Timeout::ExitException, sometimes a Timeout::Error (roughly 50/50).

beginTimeout.timeout(2)doTimeout.timeout(2)dosleep3endendrescueException=>eputs"raised a #{e.class}"end

Cause (maybe)

Hacking up the Timeout module as follows:

moduleTimeoutclassErrordefself.handle_timeout(message)# :nodoc:exc=ExitException.new(message)beginputs"yield #{exc.object_id} (#{message})"yieldexcrescueExitException=>eputs"test #{e.object_id} vs #{exc.object_id} => #{exc.equal?(e)} (#{message})"raisenew(message)ifexc.equal?(e)puts"re-raise #{e.object_id}('#{e}') (#{message})"raiseendendendendTimeout.timeout(2,nil,"outer timeout")doTimeout.timeout(2,nil,"inner timeout")dosleep3endend

shows that, when an ExitException is raised, the "inner" exception is being caught by the "outer" handle_timeout block. Suspicious this is the result of indeterminate Thread#raise behavior?

Environment

Ruby 3.3.5
Timeout 0.4.1
Ubuntu 24.04.1 running on WSL2

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