dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.32k stars 4.74k forks source link

CoreCLR tests on Mono runtime : crash running Interop/StringMarshalling/BSTR/BSTRTest/BSTRTest.sh #34375

Open SamMonoRT opened 4 years ago

SamMonoRT commented 4 years ago

Crash seen when running the following CoreCLR test on the mono runtime from the dotnet\runtime repo. Repro : Command to run individual tests : From the dotnet\runtime repo src\mono\netcore run this command or relevant one for a particular test - make run-tests-coreclr CoreClrTest="bash ../../artifacts/tests/coreclr/OSX.x64.Debug/Interop/StringMarshalling/BSTR/BSTRTest/BSTRTest.sh”

Crash report :

================================================================= External Debugger Dump:

      /Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Interop/StringMarshalling/BSTR/BSTRTest/BSTRTest.sh: line 275: 77444 Abort trap: 6           $LAUNCHER $ExePath "${CLRTestExecutionArguments[@]}"

      Return code:      1
      Raw output file:      /Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Interop/StringMarshalling/Reports/Interop.StringMarshalling/BSTR/BSTRTest/BSTRTest.output.txt
      Raw output:
      BEGIN EXECUTION
      /Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Tests/Core_Root/corerun BSTRTest.dll ''

      =================================================================
      Native Crash Reporting
      =================================================================
      Got a abrt while executing native code. This usually indicates
      a fatal error in the mono runtime or one of the native libraries 
      used by your application.
      =================================================================

      =================================================================
      Native stacktrace:
      =================================================================
      0x10c7e44b2 - /Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Tests/Core_Root/libcoreclr.dylib : mono_dump_native_crash_info
      0x10c786105 - /Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Tests/Core_Root/libcoreclr.dylib : mono_handle_native_crash
      0x10c7e3abf - /Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Tests/Core_Root/libcoreclr.dylib : sigabrt_signal_handler
      0x7fff728f342d - /usr/lib/system/libsystem_platform.dylib : _sigtramp
      0x7fff728b5167 - /usr/lib/system/libsystem_malloc.dylib : free_tiny
      0x7fff727c8a1c - /usr/lib/system/libsystem_c.dylib : abort
      0x7fff728be647 - /usr/lib/system/libsystem_malloc.dylib : has_default_zone0
      0x7fff728c140e - /usr/lib/system/libsystem_malloc.dylib : malloc_report
      0x10cbed689 - Unknown
      0x10cbea9c6 - Unknown
      0x10c6e9f9e - /Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Tests/Core_Root/libcoreclr.dylib : mono_jit_runtime_invoke
      0x10c8bf2c8 - /Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Tests/Core_Root/libcoreclr.dylib : mono_runtime_invoke_checked
      0x10c8c5645 - /Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Tests/Core_Root/libcoreclr.dylib : mono_runtime_exec_main_checked
      0x10c74402c - /Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Tests/Core_Root/libcoreclr.dylib : mono_jit_exec
      0x10c747126 - /Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Tests/Core_Root/libcoreclr.dylib : mono_main
      0x10c7c0589 - /Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Tests/Core_Root/libcoreclr.dylib : monovm_execute_assembly
      0x10c69e896 - /Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Tests/Core_Root/corerun : _Z22ExecuteManagedAssemblyPKcS0_S0_iPS0_
      0x10c69d18d - /Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Tests/Core_Root/corerun : main
      0x7fff726fa7fd - /usr/lib/system/libdyld.dylib : start

      =================================================================
      Telemetry Dumper:
      =================================================================
      Pkilling 0x123145358659584x from 0x4665851328x
      Entering thread summarizer pause from 0x4665851328x
      Finished thread summarizer pause from 0x4665851328x.

      Waiting for dumping threads to resume

      =================================================================
      Basic Fault Address Reporting
      =================================================================
      Memory around native instruction pointer (0x7fff728417fa):0x7fff728417ea  ff ff c3 90 90 90 b8 48 01 00 02 49 89 ca 0f 05  .......H...I....
      0x7fff728417fa  73 08 48 89 c7 e9 85 a2 ff ff c3 90 90 90 b8 53  s.H............S
      0x7fff7284180a  00 00 02 49 89 ca 0f 05 73 08 48 89 c7 e9 6d a2  ...I....s.H...m.
      0x7fff7284181a  ff ff c3 90 90 90 b8 83 01 00 02 49 89 ca 0f 05  ...........I....

      =================================================================
      Managed Stacktrace:
      =================================================================
        at <unknown> <0xffffffff>
        at System.Object:__icall_wrapper_mono_free_bstr <0x00078>
        at StringMarshalingTestNative:Reverse <0x00192>
        at CommonStringTests:RunStringTests <0x0016a>
        at CommonStringTests:RunTests <0x00042>
        at BStrTest:Main <0x00052>
        at <Module>:runtime_invoke_int <0x000a5>
      =================================================================
      Expected: 100
      Actual: 134
      END EXECUTION - FAILED
      Test Harness Exitcode is : 1
      To run the test:
      > set CORE_ROOT=/Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Tests/Core_Root
      > /Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/Interop/StringMarshalling/BSTR/BSTRTest/BSTRTest.sh
      Expected: True
      Actual:   False
      Stack Trace:
        /Users/samarthpatel/Documents/DotNetRunTime/runtime/artifacts/tests/coreclr/OSX.x64.Debug/TestWrappers/Interop.StringMarshalling/Interop.StringMarshalling.XUnitWrapper.cs(237,0): at Interop_StringMarshalling._BSTR_BSTRTest_BSTRTest_._BSTR_BSTRTest_BSTRTest_sh()
        /Users/samarthpatel/Documents/DotNetRunTime/runtime/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs(339,0): at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
Dotnet-GitSync-Bot commented 4 years ago

I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label.

ghost commented 4 years ago

Area Owners

@lambdageek

CoffeeFlux commented 4 years ago

Crashing function is mono_free_bstr, though locally bstr looks like a sane value (0x7fc5b9d14168):

        g_free (((char *)bstr) - 4);

I guess this is an invalid address to free so malloc is throwing an ABRT?

The test is RunStringTests in CommonStringTests.cs, with the problematic function being this:

    [DllImport(NativeLibraryName)]
    public static extern void Reverse([MarshalAs(StringMarshalingType)] string original, [MarshalAs(StringMarshalingType)] out string reversed);

No idea why it fails.

SamMonoRT commented 4 years ago

@CoffeeFlux - sending this your way

SamMonoRT commented 1 year ago

@jandupej - another one for 9.0

SamMonoRT commented 1 year ago

@fanyang-mono - we want to validate in any recent main build and see the latest state of the test.