Skip to content

Fix CancellationToken test under optimized builds - #795

Merged
emil-e merged 1 commit into
dakra:mainfrom
rfaulhaber:fix-cancellation-token-test
Nov 6, 2026
Merged

emil-e merged 1 commit into
dakra:mainfrom
rfaulhaber:fix-cancellation-token-test

Conversation

@rfaulhaber

Copy link
Copy Markdown
Contributor

The test's check callback cast away the const of the *const anyopaque context and wrote through it. Mutating memory reached through a const pointer is undefined behavior, so ReleaseSafe and ReleaseFast builds assumed context.checked unchanged across the call and the expectation failed. Packagers building with -Doptimize=ReleaseFast, as nixpkgs does, hit it running the Zig tests (this is how I discovered this issue).

Keep the context immutable and have it point at the flag instead.

The test's check callback cast away the const of the *const anyopaque
context and wrote through it.  Mutating memory reached through a const
pointer is undefined behavior, so ReleaseSafe and ReleaseFast builds
assumed context.checked unchanged across the call and the expectation
failed.  Packagers building with -Doptimize=ReleaseFast, as nixpkgs
does, hit it running the Zig tests.

Keep the context immutable and have it point at the flag instead.
@emil-e
emil-e merged commit 05468e6 into dakra:main Nov 6, 2026
@emil-e

emil-e commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

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.

2 participants