Skip to content

For function signatures with arrays, the generated PDB file crashes MSVC's msdia DLL #40477

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

Closed
staktrace opened this issue Mar 13, 2017 · 2 comments · Fixed by #42803
Closed
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.)

Comments

@staktrace
Copy link
Contributor

Backstory in https://bugzilla.mozilla.org/show_bug.cgi?id=1343625 (comment 16 has dmajor's analysis).

In summary: when building on windows, rustc can generate symbol names into the .pdb file that microsoft's DIA library doesn't like. In particular, it can result in calls to get_undecoratedNameEx to crash with a divide-by-zero. This is a bug in the DIA library which I reported to a friend at Microsoft and which has been fixed. However, older versions of the DIA library still have this problem, so rustc should probably be updated to not generate such symbols.

This bug results in the mozilla-central dump_syms.exe crashing which in turn generates a bad .sym file which causes windows debug tests to blow up. For now I have a workaround patch ready to land that catches the div-by-zero in dump_syms.exe. @luser suggested that if there is some runtime workaround (e.g. setting rustflags or something) that can avoid this problem, we should do that instead - so if there is anything I can try along those lines, please let me know.

/cc @michaelwoerister

@michaelwoerister
Copy link
Member

Thanks for the report. It looks like we are doing this on purpose for arrays we don't know the size of. I'll try to find out if we can do something else here.

@michaelwoerister
Copy link
Member

So the real culprit here is the DISubroutineType that is assigned to every function. It seems that MSDIA has a problem with fixed-size arrays of u8 or anything zero-sized. Fixed-size arrays of any other type (including i8, interestingly) are handled without crashes. Here's a table of various types and sizes I've tested:

type \ len          0     1     2     9   100
---------------------------------------------
()                        f     f     f     f
u8                  f     f     f     f     f
i8                       ok    ok    ok    ok
u16                ok    ok    ok    ok    ok
u32                ok    ok    ok    ok    ok
struct(u8)               ok    ok    ok    ok
zero-sized-struct         f     f     f     f

My proposed fix/workaround is to adapt parameter types within DISubroutineType, so that fixed-size arrays are replaced with pointers when compiling against MSVC. DISubroutineType is already inaccurate anyway, so things don't get worse at least.

@sanxiyn sanxiyn added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Jun 21, 2017
bors added a commit that referenced this issue Jun 22, 2017
debuginfo: Work around crash-bug in MSDIA library

Fixes #40477 (which also contains a description of the issue being fixed).

r? @vadimcn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants