Bug 46460 - Problem in reading double values on arm
Summary: Problem in reading double values on arm
Alias: None
Product: Runtime
Classification: Mono
Component: JIT ()
Version: 4.8.0 (C9)
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-11-04 11:36 UTC by Marek Safar
Modified: 2016-11-07 11:09 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Marek Safar 2016-11-04 11:36:13 UTC
It happens only on ARM

Unhandled Exception:
08:48:14 System.ExecutionEngineException: System.NullReferenceException: Object reference not set to an instance of an object
08:48:14   at System.Reflection.Metadata.BlobReader.ReadDouble () [0x00007] in <cd0d4ecb112745ec885569786a19c1ed>:0 
08:48:14   at Microsoft.CodeAnalysis.PEModule.GetConstantValueOrThrow (System.Reflection.Metadata.ConstantHandle handle) [0x00108] in <bededc41dc2d4bfca1b18012876b04b2>:0 
08:48:14   at Microsoft.CodeAnalysis.PEModule.GetConstantFieldValue (System.Reflection.Metadata.FieldDefinitionHandle fieldDef) [0x0001e] in <bededc41dc2d4bfca1b18012876b04b2>:0 

full log is here https://jenkins.mono-project.com/job/test-mono-pull-request-armhf/4703/consoleFull#886092580ae1da302-70c8-400e-9aed-bc1cd416a1c7

to repro clone and build https://github.com/marek-safar/mono/tree/roslyn
Comment 1 Zoltan Varga 2016-11-06 17:32:31 UTC
It tries to read an r8 value using ldind.r8:

  .method public hidebysig instance float64 
          ReadDouble() cil managed
    // Code size       9 (0x9)
    .maxstack  8
    IL_0000:  ldarg.0
    IL_0001:  ldc.i4.8
    IL_0002:  call       instance uint8* System.Reflection.Metadata.BlobReader::GetCurrentPointerAndAdvance(int32)
    IL_0007:  ldind.r8
    IL_0008:  ret
  } // end of method BlobReader::ReadDouble

ldind assumes the address is aligned, which is probably not true in this case, causing the fault. So this is a bug in roslyn.
Comment 2 Marek Safar 2016-11-07 11:09:57 UTC
Indeed, this is a bug in System.Reflection.Metadata.

Tracked it down to https://github.com/dotnet/corefx/pull/10638