test(graduation): give the width tests' tag ownership of its mesh - #499
Merged
Merged
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
make_graduation_width_test_tag built the mesh as a local and returned a tag pointing at it. A plain field only points to its mesh, so the two width tests ran graduation() on a destroyed mesh: AddressSanitizer reports a stack-use-after-return on main, and in a Release build the outcome depends on what the stack held before. It surfaced on the PRs rebased on main today, where width_zero_is_a_noop threw "interval not found at level 4098". The tag is now built on holder(mesh), so the field owns a copy of the mesh and the helper is safe by construction, the way reconstruction() already returns a field that outlives its local mesh. Returning the mesh and building the tag in each test was considered and rejected: it keeps the lifetime rule at every call site, and a one-liner passing a temporary mesh would recreate the bug silently.
gouarin
force-pushed
the
fix-graduation-test-dangling-mesh
branch
from
September 2, 2026 12:06
3057da4 to
df5c9ac
Compare
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.
Description
make_graduation_width_test_tag, added in #498, built the mesh as a local variable andreturned a tag on it. A field only points to its mesh (
inner_mesh_typestores a raw pointer),so
graduation.width_zero_is_a_noopandgraduation.width_above_dispatch_range_throwsrunsamurai::graduationon a destroyed mesh.On
mainthe two tests pass by luck: the stack slot is still intact when the tag is read. Onthe branches rebased on
maintoday (#492, #493, #494) the full test run fails withwhile the same test passes when run alone. AddressSanitizer confirms the cause on
mainitself:
The tag is now built on
holder(mesh): the field owns a copy of the mesh, so the helper is safeby construction, the way
reconstruction()already returns a field that outlives its local mesh.Returning the mesh and building the tag in each test was considered and rejected: it keeps the
lifetime rule at every call site, and a one-liner passing a temporary mesh would recreate the bug
without any warning.
How has this been tested?
tests/test_graduation.cpp, built with-fsanitize=address: the report above before thechange, clean after it,
graduation.*all passing.pre-commit run --files tests/test_graduation.cpp.Code of Conduct
By submitting this PR, you agree to follow our Code of Conduct