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

link/Elf.zig: ensure capacity before appending linker args. #21806

Merged
merged 1 commit into from
Oct 26, 2024

Conversation

xxxbxxx
Copy link
Contributor

@xxxbxxx xxxbxxx commented Oct 26, 2024

fixes e567abb "rework linker inputs"

closes #21801

Copy link
Member

@alexrp alexrp left a comment

Choose a reason for hiding this comment

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

Fix looks fine in principle.

However, given that we can't really predict how many arguments we're actually going to append, and considering that populating argv is not at all performance-sensitive, I do kind of question the value of using argv.appendAssumeCapacity() here... as opposed to just doing argv.append() like the rest of this entire function is doing, including the -whole-archive handling (which is a bit similar). Just doesn't seem worth the risk of bugs like the one we ran into here. 🤷

(To be clear, I'm referring to the argv.appendAssumeCapacity() calls below, not the one added in this PR.)

@alexrp
Copy link
Member

alexrp commented Oct 26, 2024

In any case, I've confirmed locally that this fixes the issue, so will merge as-is to unbreak master.

@alexrp alexrp merged commit 6a364b4 into ziglang:master Oct 26, 2024
10 checks passed
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.

Cannot build stage3 from HEAD: error: malloc(): unsorted double linked list corrupted
2 participants