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.
For julia 1.11+, the list of active patches (the patch env) is stored in a ScopedValue, which makes it safe to
applyinside tasks, even when those tasks are scheduled on different threads and executing concurrently. For earlier versions, the patch env is stored in a package globalRef, 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_logsuses 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.