Skip to content

Avoid a Julia 1.11 crash when fence(unordered) is caught - #28

Open
maleadt wants to merge 1 commit into
mainfrom
tb/fence-unordered
Open

maleadt wants to merge 1 commit into
mainfrom
tb/fence-unordered

Conversation

@maleadt

@maleadt maleadt commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Stack: bottom of the stack; #25 builds on this.

fence(unordered) should throw a ConcurrencyViolationError. It did so by calling Core.Intrinsics.atomic_fence(:unordered), but Julia's inference assumes that intrinsic throws an ErrorException. Julia 1.11 trusts that assumption in catch blocks and treats the caught error as the wrong type, so catching it (e.g. with @test_throws) can corrupt memory. This caused the intermittent segfaults and GC crashes in our test suite on 1.11, present since 0.3.2.

This PR throws the error directly instead. Nothing else changes. The underlying Julia bug is JuliaLang/julia#63357, with a fix in JuliaLang/julia#63360.

@maleadt
maleadt added this pull request to stack #29 September 25, 2026 13:30
@maleadt
maleadt marked this pull request as ready for review September 25, 2026 15:11
`fence(unordered)` raised its error by calling
`Core.Intrinsics.atomic_fence(:unordered)`, which throws a
ConcurrencyViolationError. Julia's inference however assumes the
intrinsic throws an ErrorException, and Julia 1.11 compiles `catch`
blocks around it accordingly: the caught error is rebuilt as an
ErrorException, and code specialized on that assumption, like a
failing `@test_throws`, corrupts memory. This crashed the test suite
on 1.11 intermittently.

Throw the ConcurrencyViolationError directly instead, on every Julia
version, so that inference sees the actual exception.
@maleadt maleadt changed the title Fix a crash on Julia 1.11 with fence(unordered) Avoid a Julia 1.11 crash when fence(unordered) is caught Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant