Bug 30825

Summary: Null string to mono_mmap_open_handle Regression between 4.1.0.1738 and 4.3.0.109
Product: [Mono] Runtime Reporter: brecon
Component: ReflectionAssignee: marcos.henrich
Status: RESOLVED FIXED    
Severity: major CC: masafa, mono-bugs+runtime
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:

Description brecon 2015-06-04 19:40:44 UTC
Using mono-4.1.0.1738 I cannot reproduce this issue, switching to mono-4.3.0.109 I can reproduce it consistently.

When I run "dnu restore" on this project: https://github.com/aspnet/dnx/tree/dev/misc/LockFileTestProjects/src/Dnx451AppReferencingNet40Lib
I get a SIGSEGV with the below callstack:

Program received signal SIGSEGV, Segmentation fault.
0x000000000062ea31 in monoeg_g_str_hash (v1=0x0) at ghashtable.c:667
667             while (*p++)
(gdb) bt
#0  0x000000000062ea31 in monoeg_g_str_hash (v1=0x0) at ghashtable.c:667
#1  0x000000000062dc6a in monoeg_g_hash_table_lookup_extended (hash=0x12d6cd0, key=0x0, orig_key=0x7fffffffb820, value=0x7fffffffb828) at ghashtable.c:328
#2  0x000000000062dbe5 in monoeg_g_hash_table_lookup (hash=0x12d6cd0, key=0x0) at ghashtable.c:311
#3  0x000000000059f6dd in mono_mmap_open_handle (input_fd=0x4, mapName=<optimized out>, capacity=0x7fffffffb930, access=1, options=<optimized out>, error=0x7fffffffb8d8) at file-mmap-posix.c:414
#4  0x00000000400d2bc8 in ?? ()
#5  0x00007ffff6f665b8 in ?? ()
#6  0x00007fffffffb960 in ?? ()
#7  0x0000000000000000 in ?? ()

And the managed stack trace:
Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.IO.MemoryMappedFiles.MemoryMapImpl.OpenHandleInternal (intptr,string,long&,System.IO.MemoryMappedFiles.MemoryMappedFileAccess,System.IO.MemoryMappedFiles.MemoryMappedFileOptions,int&) <0xffffffff>
  at System.IO.MemoryMappedFiles.MemoryMapImpl.OpenHandle (intptr,string,long&,System.IO.MemoryMappedFiles.MemoryMappedFileAccess,System.IO.MemoryMappedFiles.MemoryMappedFileOptions) <0x0004f>
  at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile (System.IO.FileStream,string,long,System.IO.MemoryMappedFiles.MemoryMappedFileAccess,System.IO.MemoryMappedFiles.MemoryMappedFileSecurity,System.IO.HandleInheritability,bool) <0x000c7>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_object_object_object_long_int_object_int_byte (object,intptr,intptr,intptr) <0xffffffff>
  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) <0xffffffff>
  at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <0x000a3>
  at System.Reflection.MethodBase.Invoke (object,object[]) <0x0002a>
  at System.Reflection.Internal.MemoryMapLightUp.CreateMemoryMap (System.IO.Stream) <0x0025f>
  at System.Reflection.Internal.StreamMemoryBlockProvider.TryCreateMemoryMappedFileBlock (long,int,System.Reflection.Internal.MemoryMappedFileBlock&) <0x00073>
  at System.Reflection.Internal.StreamMemoryBlockProvider.GetMemoryBlockImpl (int,int) <0x0006b>
  at System.Reflection.Internal.MemoryBlockProvider.GetMemoryBlock (int,int) <0x00057>
  at System.Reflection.PortableExecutable.PEReader.GetMetadataBlock () <0x0007b>
  at System.Reflection.PortableExecutable.PEReader.GetMetadata () <0x00013>
  at System.Reflection.Metadata.PEReaderExtensions.GetMetadataReader (System.Reflection.PortableExecutable.PEReader,System.Reflection.Metadata.MetadataReaderOptions,System.Reflection.Metadata.MetadataStringDecoder) <0x00033>
  at System.Reflection.Metadata.PEReaderExtensions.GetMetadataReader (System.Reflection.PortableExecutable.PEReader) <0x00013>
  at Microsoft.Framework.PackageManager.Utils.LockFileUtils.IsAssemblyServiceable (string) <0x00167>
Comment 1 marcos.henrich 2015-06-15 12:48:15 UTC
Thanks for the bug report.
Should be fixed by the following pull request:
https://github.com/mono/mono/pull/1876
Comment 2 marcos.henrich 2015-06-16 05:16:32 UTC
Fixed in master 7f3b76a32ffa62a98597ad871e088181cbf67651.
https://github.com/mono/mono/commit/7f3b76a32ffa62a98597ad871e088181cbf67651