Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@brianrob
Copy link
Member

The PE reader reads into a buffer and then slices that buffer in a loop while parsing. The previous code produced mutable references to slices of the buffer in a loop. This works fine in debug mode but breaks in release mode likely due to optimizer behavior.

This is fixed by removing the unnecessary mutable references and switching to immutable references.

The PE reader reads into a buffer and then slices that buffer in a loop
while parsing.  The previous code produced mutable references to
slices of the buffer in a loop.  This works fine in debug mode but
breaks in release mode likely due to optimizer behavior.

This is fixed by removing the unnecessary mutable references and
switching to immutable references.
@brianrob brianrob requested a review from beaubelgrave October 17, 2025 00:30
Copy link
Collaborator

@beaubelgrave beaubelgrave left a comment

Choose a reason for hiding this comment

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

LGTM, I guess mut on &mut references is something we should watch out for.

@brianrob
Copy link
Member Author

brianrob commented Oct 20, 2025

I think the issue is that there are multiple mutable borrows and the optimizer assumes that nothing will change the data except for the current mutable borrow.

@brianrob brianrob merged commit 84887d1 into microsoft:main Oct 20, 2025
8 checks passed
@brianrob brianrob deleted the dev/brianrob/fix-pe-metadata branch October 20, 2025 19:25
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