microsoft / WinDbg-Samples

Sample extensions, scripts, and API uses for WinDbg.
MIT License
702 stars 118 forks source link

Symbol Builder fails to import transitively self-referential function types #88

Closed wmessmer-msft closed 10 months ago

wmessmer-msft commented 10 months ago

When using "AutoImportSymbols = true", the symbol builder dynamically imports types and data symbols from an underlying PDB. Unfortunately, this auto import is broken for any function type symbol which has a transitive self-reference within it. If some UDT has a pointer-to-function... and the signature for that function has a return type or a parameter which refers back to that same signature (e.g.: a similar pointer-to-function), the import fails...

The first attempt to import the function type starts.... it recurses... hits the transitive reference... which attempts to import again... which succeeds (generating a new symbol with an id of 'A') ... as the recursion unwinds, the importer creates a NEW FunctionTypeSymbol at the outer level with an id of 'B'). When the importer sees that one PDB ID (for the function type symbol) maps to two DIFFERENT symbol builder IDs (both 'A' and 'B'), it fails with a catastrophic failure leaving the import half complete.

UDTs solve this issue by creating a shell of the UDT upfront and filling it in as the import progresses. Function types need to do a similar thing to deal with this.

wmessmer-msft commented 10 months ago

This should be fixed after PR #92