Skip to content

Conversation

@taalexander
Copy link
Collaborator

@taalexander taalexander commented Jan 14, 2026

Description

In LoopUnrollPatterns.inc, after replacing a cc.continue op, the code would unconditionally check if (allowBreak) and attempt to cast term (the original terminator) to a cc.break op. However, replaceOpWithNewOp erases the original operation, leaving term as a dangling pointer. This caused failures in tests on MacOS that are otherwise not normally detectable on Linux, presumably due to MacOS's more aggressive allocator.

I wasn't able to prepare a regression test as a reproducer with scribbling like in #3748 on Linux in the devcontainer. However, I could reproduce with ASAN manually on Linux (pointing to the need for a CI job to automate this):

cd build
cmake .. \
  -DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer" \
  -DCMAKE_C_FLAGS="-fsanitize=address -fno-omit-frame-pointer" \
  -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address" \
  -DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=address"

ninja cudaq-opt

lit -v test/Transforms/unroll_loop_with_break.qke

github-actions bot pushed a commit that referenced this pull request Jan 14, 2026
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Jan 15, 2026
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Jan 15, 2026
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Jan 20, 2026
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

Signed-off-by: Thomas Alexander <talexander@nvidia.com>
@taalexander taalexander force-pushed the fix/loop-unroll-use-after-free branch from 9e656f9 to ad0a96d Compare January 20, 2026 17:51
@taalexander taalexander requested a review from lmondada January 20, 2026 19:20
github-actions bot pushed a commit that referenced this pull request Jan 20, 2026
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

Copy link
Collaborator

@lmondada lmondada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@taalexander taalexander enabled auto-merge (squash) January 21, 2026 11:57
github-actions bot pushed a commit that referenced this pull request Jan 21, 2026
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

@taalexander taalexander merged commit 7a8aa1a into NVIDIA:main Jan 21, 2026
193 checks passed
github-actions bot pushed a commit that referenced this pull request Jan 21, 2026
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

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