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

Invalid debug offset invariant #247

Closed
guybedford opened this issue Jun 27, 2023 · 5 comments · Fixed by #253
Closed

Invalid debug offset invariant #247

guybedford opened this issue Jun 27, 2023 · 5 comments · Fixed by #253
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@guybedford
Copy link
Collaborator

Replication instructions in rustwasm/wasm-bindgen#3483 (comment).

The last instruction address from https://github.com/rustwasm/walrus/blob/main/src/module/debug/dwarf.rs#L214 ends up being after the subsequent function end address in https://github.com/rustwasm/walrus/blob/main/src/module/debug/dwarf.rs#L210.

Basic logging provides:

Instruction offset: 4834
Instruction offset: 4852
Instruction offset: 4859
Instruction offset: 4869
Instruction offset: 4884
Instruction offset: 4888
Instruction offset: 4898
Instruction offset: 4908
Instruction offset: 4909
Address conversion: 10337 -> 4407 (- 365 = 4042)
Function end: 4042

Where the broken invariant is then that 4909 < 4042 does not hold.

I tested the original PR and it also throws the exact same assertion so this was not an issue with the rebasing.

We maintain separate offset tables for the functions and instructions, and in this case, the instruction offsets are not present so we are falling back to the new None path in the convert_address function (which was not a part of the original Gimli implementation this came from that instead errored).

Separately, it's worth noting there's a language translation issue in the implementation where Instrument is used instead of Instruction, which might help code understanding to know.

@guybedford guybedford added the bug Something isn't working label Jun 27, 2023
@guybedford guybedford added good first issue Good for newcomers help wanted Extra attention is needed and removed good first issue Good for newcomers labels Jun 28, 2023
@Stefan-Hanke
Copy link

I'd like to tackle this - but beware I have not done system-level programming for quite some time. My main motivation is gaining experience in the rust ecosystem in general.

What I did so far:

  • Replicated the issue locally - I was glad that the code-lldb VSCode extension worked without any other configuration on Windows, and that I found about that patch table in config.toml (neat stuff)
  • Skimmed over DWARF v5 - never been that far down.
  • ... yeah and then trying to understand line programs. The spec is a difficult read for me. I found some resources but yeah, need to bite through that.

I'll now go on with generating some ELF debug-built object files (I failed to cross-compile a hello world...) and then using dwex in the hope of gaining insight.

I'd appreciate resources about line programs.

@guybedford
Copy link
Collaborator Author

@Stefan-Hanke good luck! As I say I suspect the issue is somewhere in the offset handling code landed in the original PR that added this work, the None path in convert_address did seem a bit odd to me. If you have any questions at all in looking into this, happy to help in any way I can.

@d3lm
Copy link

d3lm commented Sep 22, 2023

Is there any progress on this? I really think that having DWARF symbols for wasm-bindgen would be a really good addition an would drastically help with debugging.

@squillace
Copy link

Is there anything we can do to help finish this off here? I'd love to have rust support in vscode: rustwasm/wasm-bindgen#2389 (comment)

@guybedford
Copy link
Collaborator Author

@squillace I'll gladly review any contribution to a bug fix. This issue should still have the required context to investigate further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants