Fix VALIDATE_MARKING in the Julia GC integration - #6525
Open
fingolfin wants to merge 1 commit into
Open
Conversation
The VALIDATE_MARKING check in JMark (and the corresponding check in MarkJuliaObjSafe) requires the type of a marked object to be a live pool allocation, tested via jl_gc_internal_obj_base_ptr. Since GAP.jl became precompilable, its foreign types (GapObj, SmallBag, LargeBag) are restored from a package image via jl_reinit_foreign_type; they live in image memory, jl_gc_internal_obj_base_ptr returns NULL for them, and the first collection aborts. The same holds for the types of arbitrary Julia objects wrapped by JuliaInterface, which mostly live in the system image. Accept type objects with the in_image header bit as valid. This was investigated and fixed with the assistance of Claude Code (diagnosis, patch and testing by the AI, reviewed by a human). Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This was referenced Aug 26, 2026
fingolfin
marked this pull request as ready for review
August 26, 2026 21:05
fingolfin
added a commit
to oscar-system/GAP.jl
that referenced
this pull request
Aug 28, 2026
A GAP object held only in a C stack frame of a Julia task must survive collections that run while the task is suspended (parked in a Julia call, or busy on another thread). This went wrong when the task stack rescan optimization in GAP's julia_gc.c skipped old tasks, the cause of long-elusive crashes; see #1032, #1224 and gap-system/gap#6525. The tests hold a canary object solely via a wrapper bag in a GAP kernel argument temporary and detect premature collection through per-canary finalizers, covering automatic and explicit incremental collections and, in a subprocess with two Julia threads and two GC mark threads, a never-switching task on a second thread. Only automatic collections exercise the historically buggy path, so the driver churns allocations rather than calling GC.gc. Fixes #996. AI disclosure: tests developed with the assistance of Claude Code. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.
The
VALIDATE_MARKINGcheck inJMarkrequired the type of a marked object to be a live pool allocation, tested viajl_gc_internal_obj_base_ptr. Since GAP.jl became precompilable, its foreign types are restored from a package image and live in image memory, so the first collection aborted (the same held for types of wrapped Julia objects, which mostly live in the system image, and for the corresponding check inMarkJuliaObjSafe, which silently skipped marking). Now type objects carrying Julia'sin_imageheader bit are accepted as valid.Verified: without the fix,
using GAP(precompiled, Julia 1.12) aborts in the first collection, reproducing oscar-system/GAP.jl#1364; with it,testinstall(standalone, Julia GC) and the GAP.jl test suite pass withVALIDATE_MARKINGenabled.The CI job guarding against regressions follows in the stacked PR #6526.
AI disclosure: diagnosis, patch and testing by Claude Code, reviewed by a human.
🤖 Generated with Claude Code