Skip to content

Use a local instead of a temporary as an argument to valueOrDefault #11371

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

Merged
merged 1 commit into from
May 10, 2021

Conversation

bshastry
Copy link
Contributor

Fixes #11343

@bshastry bshastry requested a review from cameel May 10, 2021 09:35
@bshastry bshastry force-pushed the fix-asan-issue-in-functioncallgraph branch from 014cf54 to a0795cb Compare May 10, 2021 09:36
@ekpyron
Copy link
Member

ekpyron commented May 10, 2021

Hm... I wonder whether in CommonData.h we should change

	typename ValueType = std::decay_t<decltype(std::declval<MapType>().find(std::declval<KeyType>())->second)> const&,

to

	typename ValueType = std::decay_t<decltype(std::declval<MapType>().find(std::declval<KeyType>())->second)>,

instead...
(in the template arguments to valueOrDefault)

@ekpyron
Copy link
Member

ekpyron commented May 10, 2021

It's a bit tricky, though - we do want to avoid a copy there, if possible. I'd need to think about it... maybe we should also have it disallow this case without specifically passing allow_copy to it...

Copy link
Member

@ekpyron ekpyron left a comment

Choose a reason for hiding this comment

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

Approving this, since it'll work as fix, but we should rethink the behaviour of valueOrDefault in cases like this and make it safer.

@chriseth chriseth enabled auto-merge May 10, 2021 09:51
@chriseth chriseth merged commit 58bec9f into develop May 10, 2021
@chriseth chriseth deleted the fix-asan-issue-in-functioncallgraph branch May 10, 2021 10:21
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.

[FunctionCallGraph] Stack use-after-scope reported by Address sanitizer
3 participants