Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbols generated by ILAsm do not contain a PdbChecksum debug directory entry #62484

Open
clairernovotny opened this issue Dec 7, 2021 · 25 comments · May be fixed by #109091
Open

Symbols generated by ILAsm do not contain a PdbChecksum debug directory entry #62484

clairernovotny opened this issue Dec 7, 2021 · 25 comments · May be fixed by #109091
Labels
area-ILTools-coreclr in-pr There is an active PR which will close this issue when it is merged Priority:2 Work that is important, but not critical for the release
Milestone

Comments

@clairernovotny
Copy link
Member

The System.Runtime.CompilerServices.Unsafe 6.0 package does not have symbols on MSDL or NuGet's symbol server.

@ericstj

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Runtime.CompilerServices untriaged New issue has not been triaged by the area owner labels Dec 7, 2021
@ghost
Copy link

ghost commented Dec 7, 2021

Tagging subscribers to this area: @dotnet/area-system-runtime-compilerservices
See info in area-owners.md if you want to be subscribed.

Issue Details

The System.Runtime.CompilerServices.Unsafe 6.0 package does not have symbols on MSDL or NuGet's symbol server.

@ericstj

Author: clairernovotny
Assignees: -
Labels:

area-System.Runtime.CompilerServices, untriaged

Milestone: -

@safern
Copy link
Member

safern commented Dec 7, 2021

I just checked if we emmited PDBs for this project and we do. I tested it out on the 6.0 branch and we do generate the PDB and also we create a symbols package with the PDBs in it. So I wonder if this was a publishing issue or if we need to adjust the way we do publishing.

@ericstj
Copy link
Member

ericstj commented Dec 7, 2021

I think we're publishing correctly. I can see the symbols when I use symchk. What's interesting are some errors from symchk.

Public symbol server (I see the same when using the internal server)

C:\Users\erics\Downloads\system.runtime.compilerservices.unsafe.6.0.0\lib\net6.0>\debuggers\SymChk.exe -s https://msdl.microsoft.com/download/symbols -v System.Runtime.CompilerServices.Unsafe.dll
[SYMCHK] Searching for symbols to C:\Users\erics\Downloads\system.runtime.compilerservices.unsafe.6.0.0\lib\net6.0\System.Runtime.CompilerServices.Unsafe.dll in path https://msdl.microsoft.com/download/symbols
DBGHELP: Symbol Search Path: https://msdl.microsoft.com/download/symbols
[SYMCHK] Using search path "https://msdl.microsoft.com/download/symbols"
DBGHELP: No header for C:\Users\erics\Downloads\system.runtime.compilerservices.unsafe.6.0.0\lib\net6.0\System.Runtime.CompilerServices.Unsafe.dll.  Searching for image on disk
DBGHELP: C:\Users\erics\Downloads\system.runtime.compilerservices.unsafe.6.0.0\lib\net6.0\System.Runtime.CompilerServices.Unsafe.dll - OK
SYMSRV:  BYINDEX: 0x1
         https://msdl.microsoft.com/download/symbols
         System.Runtime.CompilerServices.Unsafe.pdb
         7C39E25E02074F4BAEDC1C131C0461671
SYMSRV:  UNC: C:\debuggers\sym\System.Runtime.CompilerServices.Unsafe.pdb\7C39E25E02074F4BAEDC1C131C0461671\System.Runtime.CompilerServices.Unsafe.pdb - path not found
SYMSRV:  UNC: C:\debuggers\sym\System.Runtime.CompilerServices.Unsafe.pdb\7C39E25E02074F4BAEDC1C131C0461671\System.Runtime.CompilerServices.Unsafe.pd_ - path not found
SYMSRV:  UNC: C:\debuggers\sym\System.Runtime.CompilerServices.Unsafe.pdb\7C39E25E02074F4BAEDC1C131C0461671\file.ptr - path not found
SYMSRV:  HTTPGET: /download/symbols/index2.txt
SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND
SYMSRV:  HTTPGET: /download/symbols/System.Runtime.CompilerServices.Unsafe.pdb/7C39E25E02074F4BAEDC1C131C0461671/System.Runtime.CompilerServices.Unsafe.pdb
SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND
SYMSRV:  HTTPGET: /download/symbols/System.Runtime.CompilerServices.Unsafe.pdb/7C39E25E02074F4BAEDC1C131C0461671/System.Runtime.CompilerServices.Unsafe.pd_
SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND
SYMSRV:  HTTPGET: /download/symbols/System.Runtime.CompilerServices.Unsafe.pdb/7C39E25E02074F4BAEDC1C131C0461671/file.ptr
SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND
SYMSRV:  RESULT: 0x80190194
SYMSRV:  BYINDEX: 0x2
         https://msdl.microsoft.com/download/symbols
         System.Runtime.CompilerServices.Unsafe.pdb
         7C39E25E02074F4BAEDC1C131C046167ffffffff
SYMSRV:  UNC: C:\debuggers\sym\System.Runtime.CompilerServices.Unsafe.pdb\7C39E25E02074F4BAEDC1C131C046167ffffffff\System.Runtime.CompilerServices.Unsafe.pdb - path not found
SYMSRV:  UNC: C:\debuggers\sym\System.Runtime.CompilerServices.Unsafe.pdb\7C39E25E02074F4BAEDC1C131C046167ffffffff\System.Runtime.CompilerServices.Unsafe.pd_ - path not found
SYMSRV:  UNC: C:\debuggers\sym\System.Runtime.CompilerServices.Unsafe.pdb\7C39E25E02074F4BAEDC1C131C046167ffffffff\file.ptr - path not found
SYMSRV:  HTTPGET: /download/symbols/System.Runtime.CompilerServices.Unsafe.pdb/7C39E25E02074F4BAEDC1C131C046167ffffffff/System.Runtime.CompilerServices.Unsafe.pdb
SYMSRV:  HttpQueryInfo: 801900c8 - HTTP_STATUS_OK
SYMSRV:  System.Runtime.CompilerServices.Unsafe.pdb from https://msdl.microsoft.com/download/symbols: 1740 bytes -      copied
SYMSRV:  PATH: C:\debuggers\sym\System.Runtime.CompilerServices.Unsafe.pdb\7C39E25E02074F4BAEDC1C131C046167ffffffff\System.Runtime.CompilerServices.Unsafe.pdb
SYMSRV:  RESULT: 0x00000000
DBGHELP: C:\debuggers\sym\System.Runtime.CompilerServices.Unsafe.pdb\7C39E25E02074F4BAEDC1C131C046167ffffffff\System.Runtime.CompilerServices.Unsafe.pdb - E_PDB_CORRUPT
DBGHELP: System.Runtime.CompilerServices.Unsafe - no symbols loaded
[SYMCHK] MODULE64 Info ----------------------
[SYMCHK] Struct size: 1680 bytes
[SYMCHK] Base: 0x400000
[SYMCHK] Image size: 32768 bytes
[SYMCHK] Date: 0x61734b90
[SYMCHK] Checksum: 0x000052d8
[SYMCHK] NumSyms: 0
[SYMCHK] SymType: SymNone
[SYMCHK] ModName: System.Runtime.CompilerServices
[SYMCHK] ImageName: C:\Users\erics\Downloads\system.runtime.compilerservices.unsafe.6.0.0\lib\net6.0\System.Runtime.CompilerServices.Unsafe.dll
[SYMCHK] LoadedImage: C:\Users\erics\Downloads\system.runtime.compilerservices.unsafe.6.0.0\lib\net6.0\System.Runtime.CompilerServices.Unsafe.dll
[SYMCHK] PDB: ""
[SYMCHK] CV: RSDS
[SYMCHK] CV DWORD: 0x53445352
[SYMCHK] CV Data:  D:\a\_work\1\s\artifacts\obj\System.Runtime.CompilerServices.Unsafe\net6.0-Release\System.Runtime.CompilerServices.Unsafe.pdb
[SYMCHK] PDB Sig:  0
[SYMCHK] PDB7 Sig: {7C39E25E-0207-4F4B-AEDC-1C131C046167}
[SYMCHK] Age: 1
[SYMCHK] PDB Matched:  TRUE
[SYMCHK] DBG Matched:  TRUE
[SYMCHK] Line nubmers: FALSE
[SYMCHK] Global syms:  FALSE
[SYMCHK] Type Info:    FALSE
[SYMCHK] ------------------------------------
SymbolCheckVersion  0x00000002
Result              0x00010001
DbgFilename         System.Runtime.CompilerServices.Unsafe.dbg
DbgTimeDateStamp    0x00000000
DbgSizeOfImage      0x00000000
DbgChecksum         0x00000000
PdbFilename         D:\a\_work\1\s\artifacts\obj\System.Runtime.CompilerServices.Unsafe\net6.0-Release\System.Runtime.CompilerServices.Unsafe.pdb
PdbSignature        {7C39E25E-0207-4F4B-AEDC-1C131C046167}
PdbDbiAge           0x00000001
[SYMCHK] [ 0x00000000 - 0x00010001 ] Checked "C:\Users\erics\Downloads\system.runtime.compilerservices.unsafe.6.0.0\lib\net6.0\System.Runtime.CompilerServices.Unsafe.dll"
SYMCHK: System.Runtime.CompilerServices.Unsafe.dll FAILED  - System.Runtime.CompilerServices.Unsafe.pdb mismatched or not found

SYMCHK: FAILED files = 1
SYMCHK: PASSED + IGNORED files = 0

The interesting parts seem to be:

DBGHELP: C:\debuggers\sym\System.Runtime.CompilerServices.Unsafe.pdb\7C39E25E02074F4BAEDC1C131C046167ffffffff\System.Runtime.CompilerServices.Unsafe.pdb - E_PDB_CORRUPT
DBGHELP: System.Runtime.CompilerServices.Unsafe - no symbols loaded
...
[SYMCHK] PDB Matched:  TRUE
[SYMCHK] DBG Matched:  TRUE
[SYMCHK] Line nubmers: FALSE
[SYMCHK] Global syms:  FALSE
[SYMCHK] Type Info:    FALSE

And although Line Numbers is misspelled, that's not the problem 😄 I wonder if symchk complains about the PDB in the same way from a local build, or after we run linker during the build? Perhaps isolating the error to a particular part of the build/publish pipeline can let us know where to find the issue?

@ericstj
Copy link
Member

ericstj commented Dec 7, 2021

Well, I was able to reproduce the same error when running locally, so perhaps it's a bug in ilasm?

C:\src\dotnet\runtime\artifacts\bin\System.Runtime.CompilerServices.Unsafe\net6.0-Debug>\debuggers\SymChk.exe -s .\ System.Runtime.CompilerServices.Unsafe.dll -V
...
DBGHELP: .\System.Runtime.CompilerServices.Unsafe.pdb - E_PDB_CORRUPT
...

This might be relevant: #5051

@ericstj
Copy link
Member

ericstj commented Dec 7, 2021

Also related #36664
cc @joperezr @tannergooding

@ericstj
Copy link
Member

ericstj commented Dec 8, 2021

This does appear to be unique to 6.0, but not in the way I expected.

Pre-6.0 builds of System.Runtime.CompilerServices.Unsafe look like they don't have a PDB and symchk seems to ignore them:

C:\Users\erics\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\lib\netcoreapp2.0>\debuggers\SymChk.exe -s https://msdl.microsoft.com/download/symbols -av -pf -v System.Runtime.CompilerServices.Unsafe.dll
[SYMCHK] Searching for symbols to C:\Users\erics\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\lib\netcoreapp2.0\System.Runtime.CompilerServices.Unsafe.dll in path https://msdl.microsoft.com/download/symbols
SymbolCheckVersion  0x00000002
Result              0x00000002
DbgFilename
DbgTimeDateStamp    0x00000000
DbgSizeOfImage      0x00000000
DbgChecksum         0x00000000
PdbFilename
PdbSignature        {00000000-0000-0000-0000-000000000000}
PdbDbiAge           0x00000000
[SYMCHK] [ 0x40000008 - 0x00000002 ] Checked "C:\Users\erics\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\lib\netcoreapp2.0\System.Runtime.CompilerServices.Unsafe.dll"

SYMCHK: FAILED files = 0
SYMCHK: PASSED + IGNORED files = 1

So perhaps this is the first time ILAsm is emitting PDBs in a way that SymChk can find them (perhaps it's the fitst time we're consuming 99bbb19) and SymChk doesn't like the emitted PDBs. @hoyosjs @jkotas @mikem8361 is there someone from the runtime/debugger side who can help here and have a look?

@ghost
Copy link

ghost commented Dec 8, 2021

Tagging subscribers to this area: @JulieLeeMSFT
See info in area-owners.md if you want to be subscribed.

Issue Details

The System.Runtime.CompilerServices.Unsafe 6.0 package does not have symbols on MSDL or NuGet's symbol server.

@ericstj

Author: clairernovotny
Assignees: -
Labels:

area-System.Runtime.CompilerServices, area-ILTools-coreclr, untriaged

Milestone: -

@jkotas jkotas changed the title Missing symbols for System.Runtime.CompilerServices.Unsafe Missing symbols for System.Runtime.CompilerServices.Unsafe (ilasm producing corrupt PDBs) Dec 8, 2021
@ericstj
Copy link
Member

ericstj commented Dec 8, 2021

I'm having a conversation with the debugger team about this offline. To make certain we're looking at the same thing, @clairernovotny could you please confirm you're seeing the same thing around missing symbols that I am? I want to make sure that a fix to symchk / debugger apis it uses will also fix whatever mechanism you used to identify this problem to begin with.

@JulieLeeMSFT
Copy link
Member

cc @dotnet/jit-contrib.

@hoyosjs
Copy link
Member

hoyosjs commented Dec 9, 2021

Looking at this

  • The symbol package has a portable PDB.
  • The symbol uploading process checks for Windows PDBs and uses symreader-converter to create a full PDB. For some reason the full PDB wasn't indexed in 6.0 (we had some issues with symbol conversion in 6.0.0).
  • Symchk currently only supports full PDBs well. The PDB is valid, it's just not one symchk supports. I verified, and portable PDBs were available both in symweb and msdl. I've additionally converted them to full PDB and published them:
[SYMCHK] Searching for symbols to E:\repos\dotnet-symuploader\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net6.0\System.Runtime.CompilerServices.Unsafe.dll in path https://msdl.microsoft.com/download/symbols
DBGHELP: Symbol Search Path: https://msdl.microsoft.com/download/symbols
[SYMCHK] Using search path "https://msdl.microsoft.com/download/symbols"
DBGHELP: No header for E:\repos\dotnet-symuploader\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net6.0\System.Runtime.CompilerServices.Unsafe.dll.  Searching for image on disk
DBGHELP: E:\repos\dotnet-symuploader\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net6.0\System.Runtime.CompilerServices.Unsafe.dll - OK
SYMSRV:  BYINDEX: 0x1
         https://msdl.microsoft.com/download/symbols
         System.Runtime.CompilerServices.Unsafe.pdb
         7C39E25E02074F4BAEDC1C131C0461671
SYMSRV:  UNC: C:\Debuggers\sym\System.Runtime.CompilerServices.Unsafe.pdb\7C39E25E02074F4BAEDC1C131C0461671\System.Runtime.CompilerServices.Unsafe.pdb - path not found
SYMSRV:  UNC: C:\Debuggers\sym\System.Runtime.CompilerServices.Unsafe.pdb\7C39E25E02074F4BAEDC1C131C0461671\System.Runtime.CompilerServices.Unsafe.pd_ - path not found
SYMSRV:  UNC: C:\Debuggers\sym\System.Runtime.CompilerServices.Unsafe.pdb\7C39E25E02074F4BAEDC1C131C0461671\file.ptr - path not found
SYMSRV:  HTTPGET: /download/symbols/index2.txt
SYMSRV:  HttpQueryInfo: 80190194 - HTTP_STATUS_NOT_FOUND
SYMSRV:  HTTPGET: /download/symbols/System.Runtime.CompilerServices.Unsafe.pdb/7C39E25E02074F4BAEDC1C131C0461671/System.Runtime.CompilerServices.Unsafe.pdb
SYMSRV:  HttpQueryInfo: 801900c8 - HTTP_STATUS_OK
SYMSRV:  System.Runtime.CompilerServices.Unsafe.pdb from https://msdl.microsoft.com/download/symbols: 24064 bytes - copied
SYMSRV:  PATH: C:\Debuggers\sym\System.Runtime.CompilerServices.Unsafe.pdb\7C39E25E02074F4BAEDC1C131C0461671\System.Runtime.CompilerServices.Unsafe.pdb
SYMSRV:  RESULT: 0x00000000
DBGHELP: System.Runtime.CompilerServices.Unsafe - private symbols & lines
        C:\Debuggers\sym\System.Runtime.CompilerServices.Unsafe.pdb\7C39E25E02074F4BAEDC1C131C0461671\System.Runtime.CompilerServices.Unsafe.pdb
[SYMCHK] MODULE64 Info ----------------------
[SYMCHK] Struct size: 1680 bytes
[SYMCHK] Base: 0x400000
[SYMCHK] Image size: 32768 bytes
[SYMCHK] Date: 0x61734b90
[SYMCHK] Checksum: 0x000052d8
[SYMCHK] NumSyms: 0
[SYMCHK] SymType: SymPDB
[SYMCHK] ModName: System.Runtime.CompilerServices
[SYMCHK] ImageName: E:\repos\dotnet-symuploader\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net6.0\System.Runtime.CompilerServices.Unsafe.dll
[SYMCHK] LoadedImage: E:\repos\dotnet-symuploader\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net6.0\System.Runtime.CompilerServices.Unsafe.dll
[SYMCHK] PDB: "C:\Debuggers\sym\System.Runtime.CompilerServices.Unsafe.pdb\7C39E25E02074F4BAEDC1C131C0461671\System.Runtime.CompilerServices.Unsafe.pdb"
[SYMCHK] CV: RSDS
[SYMCHK] CV DWORD: 0x53445352
[SYMCHK] CV Data:  D:\a\_work\1\s\artifacts\obj\System.Runtime.CompilerServices.Unsafe\net6.0-Release\System.Runtime.CompilerServices.Unsafe.pdb
[SYMCHK] PDB Sig:  0
[SYMCHK] PDB7 Sig: {7C39E25E-0207-4F4B-AEDC-1C131C046167}
[SYMCHK] Age: 1
[SYMCHK] PDB Matched:  TRUE
[SYMCHK] DBG Matched:  TRUE
[SYMCHK] Line nubmers: TRUE
[SYMCHK] Global syms:  TRUE
[SYMCHK] Type Info:    FALSE
[SYMCHK] ------------------------------------
SymbolCheckVersion  0x00000002
Result              0x000f0001
DbgFilename
DbgTimeDateStamp    0x61734b90
DbgSizeOfImage      0x00008000
DbgChecksum         0x000052d8
PdbFilename         C:\Debuggers\sym\System.Runtime.CompilerServices.Unsafe.pdb\7C39E25E02074F4BAEDC1C131C0461671\System.Runtime.CompilerServices.Unsafe.pdb
PdbSignature        {7C39E25E-0207-4F4B-AEDC-1C131C046167}
PdbDbiAge           0x00000001
[SYMCHK] [ 0x00000000 - 0x000f0001 ] Checked "E:\repos\dotnet-symuploader\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net6.0\System.Runtime.CompilerServices.Unsafe.dll"

SYMCHK: FAILED files = 0
SYMCHK: PASSED + IGNORED files = 1

I think this is just an artifact of properly publishing symbol packages, which slipped in 6.0.0.

@hoyosjs
Copy link
Member

hoyosjs commented Dec 9, 2021

Closing this as the symbols were already in the symbol server.

@hoyosjs hoyosjs closed this as completed Dec 9, 2021
@clairernovotny
Copy link
Member Author

I need to debug the code path here but something still isn't right:

image

The code downloads the symbols, loads the pdb and extracts information from them. The "missing symbols" could indicate an exception along the way where it wasn't able to properly load/parse the data from it.

@clairernovotny
Copy link
Member Author

I see the issue -- the PDB is missing checksums and so it cannot be validated against the original DLL.

This returns zero checksum records:

https://github.com/NuGetPackageExplorer/NuGetPackageExplorer/blob/d98979f0a561fa40221bee55623ec121f75c9099/Core/AssemblyMetadata/AssemblyDebugParser.cs#L285-L288

@clairernovotny clairernovotny reopened this Dec 9, 2021
@ericstj
Copy link
Member

ericstj commented Dec 9, 2021

I agree with @clairernovotny that we should keep this issue open until we reach an agreement on what's expected for symbols from an ILAsm-built assembly. It may require changes made to ILAsm, Debugger-APIs, and/or NuGetPackageExplorer.

@hoyosjs @jkotas is zero checksum records "normal" for this case? What does that mean for debugging?

@hoyosjs
Copy link
Member

hoyosjs commented Dec 9, 2021

PdbChecksums is an optional part of the DLL/PDB generation part. ILAsm doesn't generate it, so S.R.CS.Unsafe won't have it (I just confirmed this. Is this more of a feature request to have it?

@hoyosjs hoyosjs changed the title Missing symbols for System.Runtime.CompilerServices.Unsafe (ilasm producing corrupt PDBs) Symbols generated by ILAsm do not contain a PdbChecksum debug directory entry Dec 9, 2021
@hoyosjs
Copy link
Member

hoyosjs commented Dec 9, 2021

I agree with @clairernovotny that we should keep this issue open until we reach an agreement on what's expected for symbols from an ILAsm-built assembly. It may require changes made to ILAsm, Debugger-APIs, and/or NuGetPackageExplorer.

I mostly closed it as it was tracking availability of symbols - these were there all along and they are perfectly valid symbols. If we want to have further discussions on other components these symbols might benefit from, I am happy to do so. Yes. PDB checksum is something we can add - it requires us to change mostly ILAsm.

@hoyosjs @jkotas is zero checksum records "normal" for this case? What does that mean for debugging?

Yes. Roslyn generates these, but they are not required. It means that the debugger will only match by PDB identity (a GUID embedded in the debug directory of the PE) and any other validation might be ad hoc. The checksum allows to do a quicker/more thorough validation of the PDB identity (a hash check essentiallly) of the PDB vs the PE.

@ericstj
Copy link
Member

ericstj commented Dec 9, 2021

I see that NPE is doing this based on a copy of code from Nuget introduced here: https://github.com/NuGet/NuGet.Jobs/pull/488/files#diff-b5769d9e8d1e2dae217a8b47008c93a9bf271f72b48d8c09adbd7aa30afbd728R166
cc @cristinamanum

It seems that it was intentional in that PR (based on the description) to fail a PDB that has no checksums. I'm not sure why.

@ericstj
Copy link
Member

ericstj commented Dec 9, 2021

Oh, I think I understand why. That code is trying to make sure that the checksum in the PDB matches the binary, but it also fails if the PDB has no checksums. If we think it's valid and fine for the PDB to have no checksums then we should make a change to NPE (and NuGet.Jobs, and whereever else that logic exists) to special case a PDB with no-checksums.

@hoyosjs
Copy link
Member

hoyosjs commented Dec 9, 2021

I think it's also a good idea for security to implement checksums, but that's a feature request.

@JulieLeeMSFT
Copy link
Member

Since it is an optional feature, I am moving this to future.

@JulieLeeMSFT JulieLeeMSFT removed the untriaged New issue has not been triaged by the area owner label Apr 5, 2022
@JulieLeeMSFT JulieLeeMSFT added this to the Future milestone Apr 5, 2022
@leculver
Copy link
Contributor

leculver commented May 25, 2022

Not to resurrect a quiet thread, but I took a look at this today and I wanted to check in to see what this bug is actually tracking.

This was actually the concerning part. This sig/age being 0 meant that the pdb wasn't really accessible:

PdbSignature        {00000000-0000-0000-0000-000000000000}
PdbDbiAge           0x00000000

This looks to be fixed (see below), and the rest seems like symchk weirdness. In the next 4-6 weeks I'm looking to replace our dependence on symchk in favor of something that understands devidv symbol policies and can actually successfully verify our PDBs. For now though, it looks like the current System.Runtime.CompilerServices.Unsafe package (6.0.0) is working properly. Here's the output from symverify:

Passed.

lib/net461/System.Runtime.CompilerServices.Unsafe.dll:
    Located Artifacts:
        1. http://symweb.corp.microsoft.com/System.Runtime.CompilerServices.Unsafe.dll/61734be28000/file.ptr
        2. http://symweb.corp.microsoft.com/System.Runtime.CompilerServices.Unsafe.pdb/0e8db93d1ce04371ba54a45b8ae6a714ffffffff/file.ptr
        3. https://msdl.microsoft.com/download/symbols/System.Runtime.CompilerServices.Unsafe.dll/61734be28000/System.Runtime.CompilerServices.Unsafe.dll

lib/net6.0/System.Runtime.CompilerServices.Unsafe.dll:
    Located Artifacts:
        1. http://symweb.corp.microsoft.com/System.Runtime.CompilerServices.Unsafe.dll/61734b908000/file.ptr
        2. http://symweb.corp.microsoft.com/System.Runtime.CompilerServices.Unsafe.pdb/7c39e25e02074f4baedc1c131c046167ffffffff/file.ptr
        3. https://msdl.microsoft.com/download/symbols/System.Runtime.CompilerServices.Unsafe.dll/61734b908000/System.Runtime.CompilerServices.Unsafe.dll

lib/netcoreapp3.1/System.Runtime.CompilerServices.Unsafe.dll:
    Located Artifacts:
        1. http://symweb.corp.microsoft.com/System.Runtime.CompilerServices.Unsafe.dll/61734c098000/file.ptr
        2. http://symweb.corp.microsoft.com/System.Runtime.CompilerServices.Unsafe.pdb/fe854328d8064ca281bb50205f016f41ffffffff/file.ptr
        3. https://msdl.microsoft.com/download/symbols/System.Runtime.CompilerServices.Unsafe.dll/61734c098000/System.Runtime.CompilerServices.Unsafe.dll

lib/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll:
    Located Artifacts:
        1. http://symweb.corp.microsoft.com/System.Runtime.CompilerServices.Unsafe.dll/61734bff8000/file.ptr
        2. http://symweb.corp.microsoft.com/System.Runtime.CompilerServices.Unsafe.pdb/8edaac1d656e441baa9f2ad3b6f993a1ffffffff/file.ptr
        3. https://msdl.microsoft.com/download/symbols/System.Runtime.CompilerServices.Unsafe.dll/61734bff8000/System.Runtime.CompilerServices.Unsafe.dll

What it's saying here is that all dlls of S.R.CS.Unsafe.dll in this package have a properly generated PDB signature embedded in each dll, and that the PE Image and associated pdbs are on the symbol servers (it's not listed above, but the files are also on MSDL).

The checksum issue is less interesting/not concerning to me. These PDB/PE file checksums do not constitute a security boundary and are not used for any security process that I know of (and if they are they shouldn't be!).

It does look like old copies of this package are busted, but we can't really go back and re-ship those PE Images with proper PDB signatures embedded in them. As a result, I think we are safe to close this issue as fixed since in 6.0.0 we do embed the right information into the DLL and those PDBs are accessible via both the internal and external symbol server. Are there any objections to closing this issue, or did I miss anything? @hoyosjs? @clairernovotny?

Happy to investigate further if there's something I missed here or if there's more issues.

@hoyosjs
Copy link
Member

hoyosjs commented May 25, 2022

@leculver The package you pointed has 4 DLLs. all 4 contain this in their debug directory:

CodeView (2)
        D:\a\_work\1\s\artifacts\obj\System.Runtime.CompilerServices.Unsafe\netstandard2.0-Release\System.Runtime.CompilerServices.Unsafe.pdb, Age = 1, 8edaac1d-656e-441b-aa9f-2ad3b6f993a1

there's no PdbChecksum (record type 19) in the directory for any of the 4 dlls. That's what this is tracking. The symbols are fully indexed on all formats as needed. As far as I know, it's just an identity checksum, nothing about trust as you say. In fact, Roslyn generates the signature as the first 16 bytes of the checksum in GUID order. I don't think anything here messes with symbols or policy as you say (in fact, we don't ship this from ILASM anymore, this is now intrinsics in the runtime in 7). This only means that there;s room here to generate the record so it plays nice with download verification in debuggers, but it's just a feature.

@leculver
Copy link
Contributor

Ahh, that makes more sense! Thanks for the clarification.

Do we know of any tools (other than symchk) which rejects pdbs with a 0 checksum? Or is the feature more for just completeness sake? If we have debuggers or tools which reject pdbs with a 0 checksum then I can add that validation as part of the tooling I'm building.

@hoyosjs
Copy link
Member

hoyosjs commented May 25, 2022

Not that I know of, only small custom checks like what the NuGet package explorers which says symbols are missing if there's 0 checksum records. Debuggers like VS only do the cross-reference if such a record is there since it's an optional record - Roslyn tends to emit it. I didn't know that SymChk now fails it. The spec is at https://github.com/dotnet/runtime/blob/main/docs/design/specs/PE-COFF.md#pdb-checksum-debug-directory-entry-type-19

@TIHan TIHan added the Priority:2 Work that is important, but not critical for the release label Apr 24, 2023
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Apr 26, 2023
@TIHan
Copy link
Contributor

TIHan commented Apr 26, 2023

Still work-in-progress, but I managed to add the PdbChecksum debug directory entry: #85344

@TIHan TIHan self-assigned this Apr 27, 2023
@ghost ghost added in-pr There is an active PR which will close this issue when it is merged and removed in-pr There is an active PR which will close this issue when it is merged labels May 27, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jun 30, 2023
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 14, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 23, 2023
@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ILTools-coreclr in-pr There is an active PR which will close this issue when it is merged Priority:2 Work that is important, but not critical for the release
Projects
None yet
8 participants