-
Notifications
You must be signed in to change notification settings - Fork 110
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
Let arithmetic overflows wrap when executing line programs #508
Conversation
Similar to gimli-rs#508: The DWARF and `.eh_frame` specs don't specify how to handle overflows. So we will use wrapping.
In case of fields represented as uleb128 data, shouldn't overflow be impossible from a spec point of view? (bigint) |
Yes, and related to that, it probably also makes more sense for us to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I said in #506 that I think returning an error is better, but I'm not so sure now. This is performance sensitive and doesn't currently need any error handling so I'm not keen on adding it. I also think it's quite unlikely that toolchains will intentionally do this, but maybe they do unintentionally, and it's better for us to cope as best we can? I'm pretty sure that all other consumers are going to be doing wrapping arithmetic, so if toolchains do emit this then we'd be the only ones failing to consume it.
Btw, CI failed (in addition to not reporting the result again...) |
This makes sense when not considering what semantic data is encoded in leb128. For line numbers, I see the argument for big int semantically (but I don't think we should actually use big ints here). However PCs in the line table are not big ints, they are fixed size words of the target architecture's pointer width. To be maximally correct, I think we would want to wrap or error on overflow at that target pointer width, rather than |
Yeah, this was basically my logic as well. |
The DWARF spec isn't clear on how to handle overflow, but there is a small chance some random toolchain in the wild relies on overflow to do hacky subtraction of the current row's address. And wrapping is faster than checking for overflow and returning an error anyways. So we just do wrapping. /me shrugs Fixes gimli-rs#506
e101773
to
2b23089
Compare
The DWARF spec isn't clear on how to handle overflow, but there is a small
chance some random toolchain in the wild relies on overflow to do hacky
subtraction of the current row's address. And wrapping is faster than checking
for overflow and returning an error anyways. So we just do wrapping.
/me shrugs
Fixes #506