Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIRRTL] Fix use-after-free in InferReset #7273

Merged
merged 2 commits into from
Jul 3, 2024
Merged

Conversation

darthscsi
Copy link
Contributor

As @youngar explains well, a node was being deleted when it had references. Just route the node through the bounce wire instead of trying to replace it.

Closes #7225

As @youngar explains well, a node was being deleted when it had references.  Just route the node through the bounce wire instead of trying to replace it.

Closes #7225
nodeOp->replaceAllUsesWith(wireOp);
nodeOp.erase();
nodeOp->removeAttr(nodeOp.getInnerSymAttrName());
Copy link
Member

Choose a reason for hiding this comment

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

Should probably remove the annotations as well, e.g. if the node has an OMIR path tracker we will end up having two things with the same path tracker.

Not as important but might want to make the Node non-forcible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea working on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing the node to be non-forcable is kind of a pain as it would requiring changing the number of results, which I don't think you can do. The forcable result should be unused, so it should be cleared away with the rest of the node by CSE/Canonicalization.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes you can't change results, the way it's done is a bit rough but basically creates a new one and replaces it.

And even if you did that (there's a helper, but in the detail namespace) it'd be erasing the existing node so no-go.

Thanks!!

@dtzSiFive
Copy link
Contributor

Thanks for getting us past this.

Sounds like some bits are still coming, but please add a test (such as in the linked issue).

Copy link
Contributor

@dtzSiFive dtzSiFive left a comment

Choose a reason for hiding this comment

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

LGTM, we can fix the rest of InferResets later.

@dtzSiFive
Copy link
Contributor

Okay to land? 😁

@darthscsi darthscsi merged commit 7490529 into main Jul 3, 2024
4 checks passed
@darthscsi darthscsi deleted the dev/darthscsi/7225 branch July 3, 2024 22:27
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.

[FIRRTL] InferResets: deleting op used to drive reset network results in use-after-free
3 participants