Skip to content

syn: fix stack-use-after-return in constant fold sliceDff#10768

Closed
mguthaus wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
VLSIDA:syn-fix-sliceDff-uar
Closed

syn: fix stack-use-after-return in constant fold sliceDff#10768
mguthaus wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
VLSIDA:syn-fix-sliceDff-uar

Conversation

@mguthaus

Copy link
Copy Markdown
Contributor

Summary

sliceDff() in the constant-fold pass returned a non-owning BundleView
built from the owning Bundle that Graph::add<Dff>() returns. The implicit
BundleView(const Bundle&) conversion captures a pointer to that temporary,
which is destroyed when sliceDff() returns; foldSequentials() then indexes
the dangling view.

Fix: return an owning Bundle from sliceDff() and hold it as a Bundle at
the call site.

Type of Change

  • Bug fix

Impact

Optimized builds tolerate the UB (sliceDff is inlined, so the temporary's
storage survives the read), but a DEBUG (unoptimized) build SIGSEGVs during
synthesis of larger designs that use the integrated syn flow (e.g.
asap7/aes, asap7/jpeg). After the fix, both a pure DEBUG build and a
-DASAN=ON build complete synthesis of asap7/aes cleanly and produce
identical output (1_synth.odb sha1 matches across configs). No behavior
change for optimized builds.

Verification

  • I have verified that the local build succeeds (./etc/Build.sh).
  • I have run the relevant tests and they pass (graph_test, liveness_test
    under ASan; asap7/aes synthesis in DEBUG and ASan).

Related Issues

N/A

sliceDff() was declared to return a BundleView (a non-owning view) but
returned the owning Bundle produced by Graph::add<Dff>(). The implicit
BundleView(const Bundle&) conversion stores a pointer to that temporary,
which is destroyed when sliceDff() returns, so foldSequentials() then
indexes a dangling view (BundleView::operator[] -> Bundle::operator[]).

This is undefined behavior that optimized builds tolerate (sliceDff() is
inlined, so the temporary's storage survives the read), but a DEBUG
(unoptimized) build faults on. It reproduces as a SIGSEGV during
synthesis of larger designs using the integrated syn flow (e.g.
asap7/aes, asap7/jpeg with SYNTH_USE_SYN=1); AddressSanitizer reports a
stack-use-after-return at ir/Bundle.cc.

Return an owning Bundle from sliceDff() and hold it as a Bundle at the
call site (a BundleView local would re-create the dangle).

Signed-off-by: Matthew Guthaus <mrg@ucsc.edu>
@mguthaus mguthaus requested a review from a team as a code owner June 27, 2026 19:32
@mguthaus mguthaus requested a review from maliberty June 27, 2026 19:32

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the return type of the static helper function sliceDff in constant_fold.cc from BundleView to Bundle, and updates its usage in foldSequentials accordingly. There are no review comments, so no additional feedback is provided.

@povik

povik commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Thanks for investigating to the cause. I prefer fixing this on the Graph::add side, see #10771

@povik

povik commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Closing in favor of the other fix

@povik povik closed this Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants