Skip to content

Trace array is not thread-safe — concurrent append and clear corrupt entries #583

Description

@sdghsdkjlas27-dotcom

trace.rb appends entries via @trace << entry in the middleware, while octo.rb print_trace! reads, selects, groups, and clears @trace. Array#<< is only atomic under MRI's GIL. On JRuby/TruffleRuby, concurrent << and .clear/.select can corrupt the array. Even on MRI, print_trace! reading while another thread appends can miss entries.

REPRODUCTION: Concurrent API requests while print_trace! is called from another thread.

IMPACT: Lost trace entries, incorrect trace statistics, potential NoMethodError on JRuby.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions