-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
LLVM-backend generates COFF with invalid-length strtab entries when dynamically linking zig cc
-built C-library (SDL)
#15238
Comments
If it's deemed helpful in investigating this, I can upload the Zig-generated |
It would be more helpful if you could provide a step-by-step repro instructions. Is that a possibility? |
@kubkon Thanks for the quick response! |
@kubkon Okay, a tiny reproduction is now available at https://github.com/rohlem/Zig-invalid-coff-section-length-repro - simply clone it and |
zig cc
-built C-library (SDL)
Nice, thanks so much for this! I'll have a look shortly! |
Zig Version
0.11.0-dev.2477+2ee328995
Steps to Reproduce and Observed Behavior
I've not really been able to reduce this to a minimal example, but it's consistently happening to me on a project using some larger libraries (most notably SDL, all built with
zig cc
, though that shouldn't matter).However, if I
@panic
right inmain
, making calls to these libraries statically unreachable, it stops occurring, so it seems to be linked to overall code size/complexity.When printing a stack trace, like during a panic, they result in out-of-bounds slicing, which leads to a panicked-during-panic abort.
With debug printing I see that the length read in
std.coff.Coff.getStrtab
, + the offset, would lead to reading up to f.e.1903106884
bytes, when the length ofself.data
is only16543744
bytes.I've now also submitted PR #15239, which works around the issue.
It still needs to be investigated where these sections come from, and whether they're actually invalid or just in some other format we would also be interested in supporting.
Expected Behavior
A stack trace instead of panicking.
With #15239 just skipping invalid-length sections, the stack trace still works, so the actually relevant sections don't seem corrupted or anything afaict.
The text was updated successfully, but these errors were encountered: