rainers / cv2pdb

converter of DMD CodeView/DWARF debug information to PDB files
Artistic License 2.0
472 stars 109 forks source link

crash in CV2PDB::appendClassTypeEnum() -> memmove() #16

Closed Cauterite closed 8 years ago

Cauterite commented 8 years ago

I'm experiencing a crash in CV2PDB::appendClassTypeEnum when it attempts to memmove() a negative number of bytes.

This is an EXE file which triggers the crash for me: https://openload.co/f/K76jjq2NBl8/entrypoint.zip Generated by DMD 2.071.1 with -g on 32-bit Windows.

This is the state of the relevant variables at that point (as far as I could determine):

fieldlist =     004CAB72
type =          00002B30
name =          "__StructType"
len =           00000018
fieldlen =      0000CDCF
globalTypes =   004C9720
off =           00001452
copyoff =       0000E221
cbGlobalTypes = 00001452

memmove(dst = 0x004D7959, src = 0x004D7941, length = 0xFFFF3231);

Looks to me like fieldlen (equal to fieldlist->generic.len + 2) is much higher than it should be.

I'm not sure what other information would be helpful in diagnosing this bug, but please let me know how I can help. I'll do anything to get this fixed, I just wish I had the skills to understand what's going on here.

rainers commented 8 years ago

You are using non-ASCII characters in your identifiers. This is rather problematic with Win32 builds because DMD compresses long symbols, disregarding the fact that it's impossible later to distinguish between UTF8 encoding and compression. I've fixed the crashes and disabled decompression on fields, should be more stable now.

BTW: There is a prebuilt binary available following the link in the "Releases" tab.

Cauterite commented 8 years ago

This is great news. Thanks so much, it's working perfectly now. I never would have expected UTF identifiers to be the cause, because I use them in every project and cv2pdb hadn't choked on them before.