crossgen2 AccessViolation in ProfileDataManager.GetAllowSynthesis during win-x86 SDK crossgen layout
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Description
## Summary
crossgen2 crashes with an `AccessViolationException` while processing PGO instrumentation data during the SDK crossgen (ReadyToRun) layout step on `win-x86`. The crash occurs in `ILCompiler.ProfileDataManager.GetAllowSynthesis` and appears to be a threading/memory corruption issue in the PGO data path.
## Crash Stack
```
Process terminated. Access Violation: Attempted to read or write protected memory.
at ILCompiler.ProfileDataManager.GetAllowSynthesis(Compilation, MethodDesc, Boolean&) + 0x31
at Internal.JitInterface.CorInfoImpl.getPgoInstrumentationResults(...) + 0xab
at Internal.JitInterface.CorInfoImpl._getPgoInstrumentationResults(...) + 0x60
at Internal.JitInterface.CorInfoImpl.JitCompileMethod(...) + 0xc5
at Internal.JitInterface.CorInfoImpl.CompileMethodInternal(IMethodNode, MethodIL) + 0xc4
at Internal.JitInterface.CorInfoImpl.CompileMethod(MethodWithGCInfo, Logger) + 0x3f2
at ILCompiler.ReadyToRunCodegenCompilation.<>c__DisplayClass50_0.g__CompileOneMethod|5(...) + 0x37e
at ILCompiler.ReadyToRunCodegenCompilation.<>c__DisplayClass50_0.g__CompileOnThread|4(Int32) + 0x37
at ILCompiler.ReadyToRunCodegenCompilation.<>c__DisplayClass50_0.g__CompilationThread|3(Object) + 0x43
at System.Threading.Thread.StartThread(IntPtr)
at System.Threading.Thread.ThreadEntryPoint(IntPtr)
```
## Build
- **Pipeline:** [dotnet-unified-build (public, def 278)](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1339370)
- **Leg:** Windows_x86 (TargetRid=win-x86)
- **Phase:** SDK crossgen layout (`Crossgen.targets:171`)
- **PR:** [dotnet/dotnet#5533](https://github.com/dotnet/dotnet/pull/5533) — unrelated change (source asset signing backport)
## Analysis
- The crash is in crossgen2's PGO data processing path during multi-threaded R2R compilation.
- `CompileOnThread` → `CompileOneMethod` → `getPgoInstrumentationResults` → `GetAllowSynthesis` suggests multiple compilation threads reading `ProfileDataManager` state.
- The AV at `GetAllowSynthesis+0x31` likely dereferences a null or corrupt pointer in PGO schema data.
- **x86-only** — this targets `win-x86` (32-bit). Could be pointer truncation, address space pressure, or an x86-specific codegen bug.
- Non-deterministic — single occurrence in this window but possibly related to a parallel IBCMerge PGO crash on internal builds ([dotnet/dotnet#4138](https://github.com/dotnet/dotnet/issues/4138)), also x86-only.
## Possibly Related
[dotnet/dotnet#4138](https://github.com/dotnet/dotnet/issues/4138) — IBCMerge `BadImageFormatException` processing PGO profile data on `Windows_Pgo_x86`. Different tool (IBCMerge vs crossgen2) but same class of problem: PGO data corruption/crash isolated to x86 platforms.
Contributor guide
Assessment
This issue has not been assessed yet.