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

Merge develop into piscem-hotfix #43

Open
wants to merge 5 commits into
base: piscem-hotfix
Choose a base branch
from
Open

Merge develop into piscem-hotfix #43

wants to merge 5 commits into from

Conversation

rob-p
Copy link
Contributor

@rob-p rob-p commented Jul 16, 2024

No description provided.

jamshed and others added 5 commits June 25, 2024 16:34
The `reserve` function does not change the size of this vector, but simply ensures that *in the future*, there will be sufficient space for at least `buffer_elem_count` elements without the need to resize.

However, we later read directly into this vector and then access it without ever resizing it.  This is UB, though it has mostly compiled and behaved as one might have expected if the vector *had* been resized, probably because `reserve` is doing an eager allocation and we are reading into memory allocated by this process and later reading from that memory.

However, this UB is wrong, and recent versions of Clang are clever enough to realize this and replace access to `prefix_file_buf` directly with the `ud2` opcode, which universally produces an illegal instruction exception.

This change fixes this latent bug, which, seemingly, has existed for years, by ensuring that the vector is properly resized for the elements it will later hold, rather than simply ensuring that the *capacity* is sufficient.
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