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

Prevent stack-use-after-scope in rendering_device_driver_metal.mm #98983

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

nikitalita
Copy link
Contributor

This fixes a stack-use-after-scope error that I was getting on MacOS with sanitizers:

image

The problem is when it tries to get a reference from get_entry_points_and_stages().front(), but since the SmallVector that get_entry_points_and_stages() passes back is dynamically created, it deconstructs right after front() passes back that reference, thus we keep a reference to something that is no longer in scope.

image

Keeping that vector in scope fixes the issue.

asan.log

@nikitalita
Copy link
Contributor Author

cc @bruvzg

Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

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

Looks safe enough. If Objective-C is anything like C++ I would expect that the release builds would compile these to the same code anyway

@Repiteo Repiteo merged commit 2dbf195 into godotengine:master Nov 18, 2024
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Nov 18, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants