Skip to content

syn: fix stack-use-after-return in constant fold sliceDff, revised#10771

Open
povik wants to merge 3 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:syn-fix-sliceDff-uar
Open

syn: fix stack-use-after-return in constant fold sliceDff, revised#10771
povik wants to merge 3 commits into
The-OpenROAD-Project:masterfrom
The-OpenROAD-Project-staging:syn-fix-sliceDff-uar

Conversation

@povik

@povik povik commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

This is a revised fix from #10768.

Since the return value of add represents a contiguous block of net indices we can use BundleView for it which is both more efficient and prevents use-after-free should the caller cast to BundleView.

Type of Change

  • Bug fix

@povik povik self-assigned this Jun 28, 2026

@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 Graph::add function from Bundle to BundleView in both its declaration and definition. The review feedback suggests updating the corresponding documentation comment to reflect this change. Additionally, it recommends optimizing the Bundle::Bundle(BundleView) constructor to prevent unnecessary heap allocations when callers assign the returned BundleView to a Bundle, particularly since Graph::add returns consecutive nets.

Comment thread src/syn/src/ir/Graph.h Outdated
Comment thread src/syn/src/ir/Graph.h
@povik

povik commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

The LLM has good suggestions, I'll take them up later.

mguthaus and others added 3 commits June 29, 2026 18:01
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>
Since the return value of `add` represents a contiguous block of net
indices we can use `BundleView` for it which is both more efficient and
prevents use-after-free should the caller cast to BundleView.

Signed-off-by: Martin Povišer <povik@cutebit.org>
Signed-off-by: Martin Povišer <povik@cutebit.org>
@openroad-ci openroad-ci force-pushed the syn-fix-sliceDff-uar branch from a815a5e to 060af12 Compare June 29, 2026 16:50
@povik povik marked this pull request as ready for review June 29, 2026 16:52
@povik povik requested a review from a team as a code owner June 29, 2026 16:52
@povik povik requested a review from maliberty June 29, 2026 16:52
@povik

This comment was marked as off-topic.

@chatgpt-codex-connector

This comment was marked as off-topic.

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