rainers / cv2pdb

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

crash when openmp is used (null pointer in typedef name) #8

Closed l0calh05t closed 8 years ago

l0calh05t commented 9 years ago

I am using cv2pdb to convert DLLs generated with MinGW-w64 from DWARF to PDB. I recently started using OpenMP in that project. This causes cv2pdb to crash because now addUdtSymbol is being called with a null name from CV2PDB::createTypes, more specifically in these lines:

case DW_TAG_typedef:
    cvtype = appendModifierType(getTypeByDWARFPtr(cu, id.type), 0);
    addUdtSymbol(cvtype, id.name);

For now I just added if(!name) return false; to the beginning of CV2PDB::addUdtSymbol.

Minimal example:

Add the following to a new file, e.g., cv2pdb_crash.cpp:

__declspec(dllexport) void foo(int I)
{
    #pragma omp parallel for
    for(int i = 0; i < I; i++)
        continue;
}

Build a DLL: g++ -fopenmp -O0 -g -shared cv2pdb_crash.cpp -o cv2pdb_crash.dll

Run cv2pdb: cv2pdb -C cv2pdb_crash.dll

Observe crash.

rainers commented 9 years ago

Thanks for the report.

It's probably better to allow adding these "anonymous" UDT. IIRC the types referred to don't work properly in the debugger if there are no corresponding UDT entries.

I have pushed an appropriate patch to master.

l0calh05t commented 9 years ago

Ok. I didn't actually try debugging anything with my workaround.