This is an archive of the discontinued LLVM Phabricator instance.

[llvm-pdbutil] Don't crash when printing unknown CodeView type records
ClosedPublic

Authored by aganea on Dec 22 2020, 11:22 AM.

Details

Summary

It seems Microsoft has added some new, undocumented, debug type records with the (latest?) VS 2019 16.8 release. For example:

>cat a.cpp
namespace NS {
  struct Foo {
    explicit Foo(int x) : X(x) {}
    int X;
  };
}

int main(int argc, char **argv) {
  NS::Foo f(argc);
  return 0;
}

>cl /c /Z7 /GS- a.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29335 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

a.cpp

>cvdump.exe a.obj | grep "UNRECOGNIZED"
0x1004 : Length = 46, Leaf = 0x1609 UNRECOGNIZED TYPE
0x1009 : Length = 46, Leaf = 0x1609 UNRECOGNIZED TYPE

Before this patch, llvm-pdbutil dump a.obj used to crash. Now it displays "UNKOWN RECORD":

>llvm-pdbutil dump -all a.obj | grep -C2 "0x1609"
                Record Kind | Count  Size
    --------------------------------------
    UNKNOWN RECORD (0x1609) |     1    48
    --------------------------------------
              Total (S_UDT) |     1    16
--
0x1003 | LF_FUNC_ID [size = 20]
         name = main, type = 0x1002, parent scope = <no type>
0x1004 | UNKNOWN RECORD (0x1609) [size = 48]
0x1005 | LF_POINTER [size = 12]
         referent = 0x1004, mode = pointer, opts = const, kind = ptr64
--
           type = 0x1007, vftable offset = -1, attrs = public
         - LF_MEMBER [name = `X`, Type = 0x0074 (int), offset = 0, attrs = public]
0x1009 | UNKNOWN RECORD (0x1609) [size = 48]
0x100A | LF_STRING_ID [size = 48] ID: <no type>, String: F:\aganea\llvm-project\__test\a.cpp
0x100B | LF_UDT_SRC_LINE [size = 16]

There's also a crash in obj2yaml as well, I can send another review for that.

@gratianlup Do you think if it would be possible to to upgrade the list of records in https://github.com/microsoft/microsoft-pdb ? Thanks in advance!

Diff Detail

Event Timeline

aganea created this revision.Dec 22 2020, 11:22 AM
aganea requested review of this revision.Dec 22 2020, 11:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 22 2020, 11:22 AM
rnk accepted this revision.Jan 5 2021, 4:47 PM

lgtm

It seems like Harbormaster / Jenkins didn't like the new test, so double check that it passes before landing.

This revision is now accepted and ready to land.Jan 5 2021, 4:47 PM
This revision was landed with ongoing or failed builds.Jan 7 2021, 12:45 PM
This revision was automatically updated to reflect the committed changes.