Repository navigation
Closed
Labels
Milestone
Description
Hello,
Description
In dotnet 8 RC2 AOT, Windbg bm command inserts breakpoints in data sections, causing crash because the breakpoint instructions corrupt AOT runtime data structures.
Reproduction Steps
Program:
Activator.CreateInstance(typeof(GreatTest));
class GreatTest
{
public GreatTest()
{
}
}Csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<PublishAot>true</PublishAot>
</PropertyGroup>
</Project>Build: dotnet publish
Upon LdrpDoDebuggerBreak, do bm AotDbgCrash!*GreatTest*. This will resolve the ctor, but also runtime data structures for NativeAOT. The expected behavior is that bm wildcards should resolve only functions, not data:
0:000> bm AotDbgCrash!*GreatTest*
0: 00007ff7`933e82c8 @!"AotDbgCrash!__writableDataAotDbgCrash_GreatTest"
1: 00007ff7`932acb00 @!"AotDbgCrash!AotDbgCrash_GreatTest___ctor"
The insertion of a breakpoint at #0 bricks the runtime.
(81d8.3944): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
AotDbgCrash!S_P_CoreLib_System_Type__GetTypeFromHandle+0x1e:
00007ff6`a4b57dee 488b01 mov rax,qword ptr [rcx] ds:00000000`000000cc=????????????????
0:000> k
# Child-SP RetAddr Call Site
00 000000f6`494ff860 00007ff7`932acadc AotDbgCrash!S_P_CoreLib_Internal_Runtime_CompilerHelpers_LdTokenHelpers__GetRuntimeType+0x1c [/_/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/LdTokenHelpers.cs @ 36]
01 000000f6`494ff890 00007ff7`932cb860 AotDbgCrash!AotDbgCrash_Program___Main__+0x1c [C:\Users\bfrancis\source\repos\AotDbgCrash\AotDbgCrash\Program.cs @ 1]
02 000000f6`494ff8c0 00007ff7`931c22d2 AotDbgCrash!AotDbgCrash__Module___StartupCodeMain+0xe0
Activity
jkotas commentedon Nov 13, 2023
bmcommand finds a match for the ctor, but also forwriteableDataruntime data structure:Setting the breaking on
writeableDatacorrupts the data structure that leads to the crash.Can we do something to prevent
bmfrom matching thewriteableData?MichalStrehovsky commentedon Nov 13, 2023
Per WinDbg docs,
bmis supposed to match only code unless/awas specified.The
writableDatablocks are in a data section of the executable so if WinDbg was following what the docs are saying, it shouldn't write in that location. Unless there's some other mechanism to decide if something is code or data.jkotas commentedon Nov 13, 2023
@mikem8361 Do you have any insights into why windbg
bmcommand sets breaking in data section in this case?mikem8361 commentedon Nov 13, 2023
Sorry I don't. I'll send the windows debugger team this issue.
fbrosseau commentedon Nov 14, 2023
Thank you folks I updated the opening post for a better description