Skip to content

Not threadsafe (or possibly even async-safe) on Julia 1.10 #146

Description

@kleinschmidt

For julia 1.11+, the list of active patches (the patch env) is stored in a ScopedValue, which makes it safe to apply inside tasks, even when those tasks are scheduled on different threads and executing concurrently. For earlier versions, the patch env is stored in a package global Ref, which is definitely not concurrency friendly lol.

IIUC, the reason we're not using the ScopedValues.jl fallback is because it uses the logging machinery on julia <1.11 to smuggle in scoped values, and this in turn interferes with the test logger that @test_logs uses to, you know, test logging.

It seems really bad to me that there's silently, inconsistently thread-unsafe application of patches in some versions of julia but not others. I'd rather we allow users to opt out of using the ScopedValues fallback if they need to. I think it would be possible to allow users to control whether a global ref is used or a scoped value with a configuration option, like a boolean flag ref that can be set.

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