Repository navigation
Fix false llvm.assumes in wake_thread! (segfault on Julia nightly) - #67
Merged
Merged
Conversation
Base.Workqueues() is the current thread's work queue, so its length is the number of queued tasks, not the number of threads. The assumption length(Base.Workqueues()) > tid is false in general; LLVM 22 (Julia 1.14) uses it to drop the nothing check in the IntrusiveLinkedList length loop, which then dereferences nothing and segfaults in the first @Batch launch. Use Threads.maxthreadid() instead, and fix the TASKS bound (tid, not tid + 1, indexes TASKS). Assisted-by: Claude Code (Opus 5.5)
Assisted-by: Claude Code (Opus 5.5)
vchuravy
force-pushed
the
vc/fix-wake-thread-assume
branch
from
October 13, 2026 18:46
15fd22d to
4f1a898
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67 +/- ##
==========================================
- Coverage 99.20% 94.44% -4.77%
==========================================
Files 4 4
Lines 126 126
==========================================
- Hits 125 119 -6
- Misses 1 7 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #66.
#64 changed the bound in
wake_thread!toassume(unsigned(length(Base.Workqueues())) > unsigned(tid)). On Julia 1.13+,Base.Workqueues()is the current thread's work queue, and itslengthis the number of tasks queued on that thread, not the number of threads. So the assumption is false, which is undefined behaviour.length(::IntrusiveLinkedList)loop, which then segfaults (Fault at memory address: 0x1d3) on the firstPolyester.@batchlaunch with 2 or more threads.This PR:
Threads.maxthreadid() > tidinstead. The function readsBase.Workqueues[tid + 1], which needs exactly that bound.assume(length(TASKS) > tid + 1). That assumption is false for the last worker (always at-t 2). It is nowlength(TASKS) >= tid, which matches theTASKS[tid]access.ci-julia-nightly.yml) weekly on a schedule, and allows starting it by hand.Testing
JULIA_NUM_THREADS=4,Pkg.test():wake_thread!With the fix, the reproducers in #66 and Trixi.jl (Polyester backend,
-t 2and-t 8) also run on nightly.The nightly workflow (
ci-julia-nightly.yml) runs only on pull requests and pushes tomain. Its last run was on 2026-05-29, before the nightly LLVM update that exposes this bug, so it never saw the crash. The second commit adds a weeklyschedule(andworkflow_dispatch) to that workflow so that changes in Julia nightly are caught without a change in this repository. A patch release after merging would unblock Polyester users on nightly.This PR was prepared with assistance from Claude Code (Anthropic's AI coding assistant). I reviewed the changes.
🤖 Generated with Claude Code