- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.2k
Closed
Description
On linux and osx hosts, crossgen r2rdump fails for a subset of tests right now fairly consistently, where the RVA of the auxiliary data points to the exact end of the .text section's virtual address space. There should be 4 bytes there, representing the length of the auxiliary data, or a NULL to indicate there is no auxiliary data. This does not appear to fail on windows, which seems to align with the comment in R2RPEBuilder.cs that suggests it doesn't patch any section headers on Windows:
        /// <summary>
        /// On Linux, we must patch the section headers. This is because the CoreCLR runtime on Linux
        /// requires the 12-16 low-order bits of section RVAs (the number of bits corresponds to the page
        /// size) to be identical to the file offset, otherwise memory mapping of the file fails.
        /// Sadly PEBuilder in System.Reflection.Metadata doesn't support this so we must post-process
        /// the EXE by patching section headers with the correct RVA's. To reduce code variations
        /// we're performing the same transformation on Windows where it is a no-op.
        /// </summary>
        /// <param name="outputStream"></param>
        private void UpdateSectionRVAs(Stream outputStream)Example with additional diagnostic data from PR #106099:
Running CrossGen2:  /tmp/helix/working/A5660909/p/crossgen2/crossgen2 @/private/tmp/helix/working/A5660909/w/B1E409AA/e/JIT/Methodical/xxobj/sizeof/sizeof32_Target_64Bit_and_arm_d/composite-r2r.dll.rsp   --composite
Emitting R2R PE file: /private/tmp/helix/working/A5660909/w/B1E409AA/e/JIT/Methodical/xxobj/sizeof/sizeof32_Target_64Bit_and_arm_d/composite-r2r.dll
Emitting R2R PE file: /private/tmp/helix/working/A5660909/w/B1E409AA/e/JIT/Methodical/xxobj/sizeof/sizeof32_Target_64Bit_and_arm_d/sizeof32_Target_64Bit_and_arm_d.dll
Running R2RDump:  dotnet /tmp/helix/working/A5660909/p/R2RDump/R2RDump.dll --header --sc --in /private/tmp/helix/working/A5660909/w/B1E409AA/e/JIT/Methodical/xxobj/sizeof/sizeof32_Target_64Bit_and_arm_d/composite-r2r.dll --out /private/tmp/helix/working/A5660909/w/B1E409AA/e/JIT/Methodical/xxobj/sizeof/sizeof32_Target_64Bit_and_arm_d/composite-r2r.dll.r2rdump --val
Error: System.BadImageFormatException: Failed to convert invalid RVA to offset: 67192.
Sections:
.text PTRD=1024 SORD=1024 VA=66560 VS=632
.data PTRD=2048 SORD=1024 VA=198656 VS=1014
.edata PTRD=3072 SORD=512 VA=330752 VS=84
.reloc PTRD=3584 SORD=512 VA=462336 VS=12
at ILCompiler.Reflection.ReadyToRun.PEReaderExtensions.GetOffset(PEReader reader, Int32 rva) in //src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/PEReaderExtensions.cs:line 116
at ILCompiler.Reflection.ReadyToRun.ReadyToRunReader.EnsureImportSections() in //src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunReader.cs:line 1456
at R2RDump.TextDumper.DumpSectionContents(ReadyToRunSection section) in //src/coreclr/tools/r2rdump/TextDumper.cs:line 435
at R2RDump.TextDumper.DumpSection(ReadyToRunSection section) in //src/coreclr/tools/r2rdump/TextDumper.cs:line 120
at R2RDump.TextDumper.DumpHeader(Boolean dumpSections) in //src/coreclr/tools/r2rdump/TextDumper.cs:line 81
at R2RDump.Program.Dump(ReadyToRunReader r2r) in //src/coreclr/tools/r2rdump/Program.cs:line 166
at R2RDump.Program.Run() in /_/src/coreclr/tools/r2rdump/Program.cs:line 460
The artifacts for these failed runs don't appear to contain the actual binaries, which might be related to this:
cp: /tmp/helix/working/A5660909/p/libsuperpmi-shim-simple.dylib is not a directory
DOTNET_DbgEnableMiniDump is set and the createdump binary does not exist: /private/tmp/helix/working/A5660909/p/crossgen2/createdump