Skip to content

bug: generated pdb cannot be read by sentry.io (wrong machine type, missing section headers) #20

@mcdurdin

Description

@mcdurdin

Thanks for your work in creating map2pdb!

We are trying to use map2pdb to integrate our app Keyman more cleanly with Sentry -- currently we use .dbg but those are somewhat limited. However, Sentry reported that the .pdb files generated by map2pdb are not parseable by them. They noted a few issues:

So far it looks like your Delphi application is built as Win32 (32-bit/x86), but the PDB is being detected as x86_64 (64-bit). This is a significant mismatch. The map2pdb tool is likely generating a PDB file with an incorrect MachineType. In the symbolic crate's PDB handling (pdb.rs), the architecture is determined from the PDB's DBI stream's machine type. For a 32-bit Delphi build, this should be MachineType::X86 (value 0x014c), not Amd64 (value 0x8664).

Another thing I noticed is that even though Sentry reports the PDB was found with "has_debug_info": true and "has_symbols": true, the actual symbolication fails with "symbolicator_status": "missing_symbol" for all your application frames. The symbolic library converts internal PDB section offsets to RVAs using an address map (pdb.rs). If to_rva() returns None, the function is skipped entirely. This happens when:

  • The PDB lacks proper section headers
  • The section offset doesn't map to a valid RVA
  • The address map (OMAP stream) is missing or invalid

What's most likely happening here is that the map2pdb tool converts Delphi's .map file format to PDB format, but it may not be generating a fully compatible PDB because of:

  • Wrong machine type in the DBI stream header
  • Missing or incorrect section headers that the address map needs to translate section:offset pairs to RVAs
  • Address mapping issues: Delphi .map` files use segment:offset notation that needs proper conversion

I tried to examine the generated .pdb with cvdump but found that it could not be read due to a missing dbgtypeSectionHdr stream. However, I did see in the code that IMAGE_FILE_MACHINE_AMD64 is always written, so that part of the analysis at least is correct:

DBIStreamHeader.Machine := IMAGE_FILE_MACHINE_AMD64;

dbgtypeSectionHdr appears to be a list of IMAGE_SECTION_HEADERs:

https://github.com/microsoft/microsoft-pdb/blob/805655a28bd8198004be2ac27e6e0290121a5e89/cvdump/dumppdb.cpp#L2340

I have not at this point attempted to create a patch for this but would be happy to work with you to address these issues.

Keyman issue: keymanapp/keyman#15182

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions