Skip to content

Rework global variables, caching to eliminate race conditions #4808

@headius

Description

@headius

This issue spawned from discoveries in #4797, where @eregon discovered that various races in our global variable subsystem seem to be causing us to cache invalid values.

There are numerous races, including but not limited to:

  • GlobalVariables uses a CHM but manually performs multi-step read/write operations that would race with other threads.
  • UndefinedVariable modifies the GlobalVariable it was attached to, updating it with a different accessor. This makes caching the accessor impossible.
  • The traces active for each global variable are managed in an unsynchronized ArrayList, which additionally can be modified from outside the subsystem.

There are likely others. The main problems lie in the fact that this part of JRuby is some of the oldest code, many files only bearing the copyright of the first committer to JRuby. None of this code was built for concurrency, and the many levels of abstraction and mutation make a simple fix impossible.

This bug will track a rework of the global variable subsystem for JRuby 9.2, which will eliminate some of the unnecessary abstraction, use appropriate thread-safe structures and synchronization for modification, and properly enable safe caching of values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions