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

Quick fix for MacroRuleDefinition use-after-free #2676

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

powerboat9
Copy link
Contributor

Macro expansion seems to destruct instances of MacroRulesDefinition in modules. This patch should prevent a use-after-free by cloning and then leaking MacroRulesDefinition instances.

Macro expansion seems to destruct instances of
MacroRulesDefinition in modules. This patch should
prevent a use-after-free by cloning and then leaking
MacroRulesDefinition instances.

gcc/rust/ChangeLog:

	* ast/rust-macro.h
	(MacroRulesDefinition::clone_macro_rules_def): New.
	* util/rust-hir-map.cc
	(Mappings::insert_macro_invocation):
	Clone, and then leak, the MacroRulesDefinition.

Signed-off-by: Owen Avery <[email protected]>
@powerboat9
Copy link
Contributor Author

Converting this to a draft for a bit, just to make sure I understand the issue

@powerboat9 powerboat9 marked this pull request as draft October 11, 2023 03:33
@CohenArthur
Copy link
Member

do you have a Rust example where this causes a use-after-free? ASAN will probably be helpful with this, if you'd like I can send in my configure line and make command to use ASAN without the build crashing at the first memory leak in g++

@powerboat9
Copy link
Contributor Author

do you have a Rust example where this causes a use-after-free?

Not yet, that's why I converted this to a draft :P

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