Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnwindManagedExceptionPass1 is failing on illumos amd64 #38373

Closed
am11 opened this issue Jun 25, 2020 · 5 comments
Closed

UnwindManagedExceptionPass1 is failing on illumos amd64 #38373

am11 opened this issue Jun 25, 2020 · 5 comments
Labels
area-ExceptionHandling-coreclr os-SunOS SunOS, currently not officially supported untriaged New issue has not been triaged by the area owner

Comments

@am11
Copy link
Member

am11 commented Jun 25, 2020

With a simple app that throws exception:

using System;
class Program
{
    static void Main(string[] args)
    {
        if (Array.IndexOf(args, "--throw") > -1)
            try
            {
                throw new Exception("Hello exception!");
            }
            catch (Exception ex)
            {
               Console.WriteLine(ex.Message);
               throw;
            }
...

after the exception is rethrown and message is printed to stderr, application abort()s on SmartOS amd64.

$ LD_PRELOAD=/lib/amd64/libumem.so ~/.dotnet/dotnet test-app/bin/Debug/net5.0/publish/test-app.dll --throw

Hello exception!
Unhandled exception. System.Exception: Hello exception!
   at test-app.Program.Main(String[] args)
Abort (core dumped)

On Linux, it cleanly exits the process (without abort()).

coredump inspection yields:

$ sudo mdb /var/cores/dotnet.df333bd6-c7f8-63b6-b1c2-e947d740e084.6546.1593009420.core 
mdb: core file data for mapping at fffffc7f4d822000 not saved: Bad address
mdb: core file data for mapping at fffffc7f5d812000 not saved: Bad address
mdb: core file data for mapping at fffffc7f65802000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6d810000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6d851000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6d85e000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6d861000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6d867000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6d871000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6d875000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6d8a6000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6d978000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6d9ee000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6dc6f000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6de7d000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6df59000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6e00c000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6e08f000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6e0e8000 not saved: Bad address
mdb: core file data for mapping at fffffc7f6e0f6000 not saved: Bad address
mdb: core file data for mapping at fffffc7fed8a1000 not saved: Bad address
mdb: core file data for mapping at fffffc7fee1a0000 not saved: Bad address
mdb: core file data for mapping at fffffc7fee490000 not saved: Bad address
mdb: core file data for mapping at fffffc7fee6a0000 not saved: Bad address
mdb: core file data for mapping at fffffc7fef000000 not saved: Bad address
mdb: core file data for mapping at fffffc7fef00f000 not saved: Bad address
mdb: core file data for mapping at fffffc7fef012000 not saved: Bad address
mdb: core file data for mapping at fffffc7fef040000 not saved: Bad address
mdb: core file data for mapping at fffffc7fef050000 not saved: Bad address
Loading modules: [ libumem.so.1 libc.so.1 ld.so.1 ]
> ::status
debugging core file of dotnet (64-bit) from df333bd6-c7f8-63b6-b1c2-e947d740e084
file: /home/am11/.dotnet/dotnet
initial argv: /home/am11/.dotnet/dotnet test-app/bin/Debug/net5.0/publish/test-app.dll
threading model: native threads
status: process terminated by SIGABRT (Abort), pid=6546 uid=1000 code=-1
> $C
fffffc7fffdfbed0 libc.so.1`_lwp_kill+0xa()
fffffc7fffdfbf00 libc.so.1`raise+0x1e(6)
fffffc7fffdfbf50 libc.so.1`abort+0x58()
fffffc7fffdfbf60 libcoreclr.so`InitializeFlushProcessWriteBuffers()
fffffc7fffdfbfc0 libcoreclr.so`_ZL14PROCEndProcessPvji+0x3b1()
fffffc7fffdfc000 libcoreclr.so`TerminateProcess+0xbd()
fffffc7fffdfc020 libcoreclr.so`_Z28CrashDumpAndTerminateProcessj+0x20()
fffffc7fffdfc6c0 libcoreclr.so`_Z27UnwindManagedExceptionPass1R16PAL_SEHExceptionP8_CONTEXT+0x628()
fffffc7fffdfcc30 libcoreclr.so`_Z24DispatchManagedExceptionR16PAL_SEHExceptionb+0x110()
fffffc7fffdfcde0 libcoreclr.so`_Z10IL_Rethrowv+0x1f0()
fffffc7fffdfe5f0 0xfffffc7f6d9ca14f()
fffffc7fffdfe610 libcoreclr.so`CallDescrWorkerInternal+0x7c()
fffffc7fffdfe680 libcoreclr.so`_Z26CallDescrWorkerWithHandlerP13CallDescrDatai+0x11b()
fffffc7fffdfe8c0 libcoreclr.so`_ZN18MethodDescCallSite16CallTargetWorkerEPKmPmi+0x8ef()
fffffc7fffdfe8e0 libcoreclr.so`_ZN18MethodDescCallSite4CallEPKm+0x2a()
fffffc7fffdfea60 libcoreclr.so`_ZL15RunMainInternalP5Param+0x26b()
fffffc7fffdfea80 libcoreclr.so`_ZZZ7RunMainP10MethodDescsPiP3REFI8PtrArrayEENKUlP5ParamE_clES7_ENKUlS7_E_clES7_+0x1c()
fffffc7fffdfeb00 libcoreclr.so`_ZZ7RunMainP10MethodDescsPiP3REFI8PtrArrayEENKUlP5ParamE_clES7_+0x5f()
fffffc7fffdfebe0 libcoreclr.so`_Z7RunMainP10MethodDescsPiP3REFI8PtrArrayE+0x1db()
fffffc7fffdfee90 libcoreclr.so`_ZN8Assembly17ExecuteMainMethodEP3REFI8PtrArrayEi+0x113()
fffffc7fffdff010 libcoreclr.so`_ZN8CorHost215ExecuteAssemblyEjPKDsiPS1_Pj+0x3ff()
fffffc7fffdff0d0 libcoreclr.so`coreclr_execute_assembly+0x127()
fffffc7fffdff110 libhostpolicy.so`_ZN9coreclr_t16execute_assemblyEiPPKcS1_Pj+0x7c()
fffffc7fffdff250 libhostpolicy.so`_Z19run_app_for_contextRK20hostpolicy_context_tiPPKc+0x44b()
fffffc7fffdff2a0 libhostpolicy.so`_Z7run_appiPPKc+0x6d()
fffffc7fffdff450 libhostpolicy.so`corehost_main+0x15b()
fffffc7fffdff540 libhostfxr.so`_ZL11execute_appRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEP15corehost_init_tiPPKc+0x2f2()
fffffc7fffdff5e0 libhostfxr.so`_ZN12_GLOBAL__N_123read_config_and_executeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERK19host_startup_info_tS7_RKSt13unordered_mapI13known_optionsSt6vectorIS5_SaIS5_EE18known_options_hashSt8equal_toISC_ESaISt4pairIKSC_SF_EEEiPPKc11host_mode_tPciPi+0xd7()
fffffc7fffdff6a0 libhostfxr.so`_ZN10fx_muxer_t24handle_exec_host_commandERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERK19host_startup_info_tS7_RKSt13unordered_mapI13known_optionsSt6vectorIS5_SaIS5_EE18known_options_hashSt8equal_toISC_ESaISt4pairIKSC_SF_EEEiPPKci11host_mode_tPciPi+0x175()
fffffc7fffdff7a0 libhostfxr.so`_ZN10fx_muxer_t7executeENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiPPKcRK19host_startup_info_tPciPi+0x166()
fffffc7fffdff890 libhostfxr.so`hostfxr_main_startupinfo+0xac()
fffffc7fffdffa30 _Z9exe_startiPPKc+0x49c()
fffffc7fffdffa60 main+0xa5()
fffffc7fffdffa90 _start_crt+0x83()
fffffc7fffdffaa0 _start+0x18()

From libunwind, we hit this condition:

then in UnwindManagedExceptionPass1, since we are at IP==0, we get here:

CrashDumpAndTerminateProcess(1);

stress trace looks like this:

Hello exception!
Processing exception at native frame: IP = FFFFFC7FE73925C4, SP = FFFFFC7FFFDFCE40 
Processing exception at native frame: IP = FFFFFC7FE7393463, SP = FFFFFC7FFFDFCED0 
Processing exception at native frame: IP = FFFFFC7FE7399D87, SP = FFFFFC7FFFDFCFA0 
Processing exception at native frame: IP = FFFFFC7FE739A369, SP = FFFFFC7FFFDFD1B0 
Processing exception at native frame: IP = FFFFFC7FE739AAD0, SP = FFFFFC7FFFDFD7E0 
Processing exception at native frame: IP = FFFFFC7FE72AE791, SP = FFFFFC7FFFDFDE80 
Processing exception at native frame: IP = FFFFFC7F6D5CA105, SP = FFFFFC7FFFDFE3F0 
Processing exception at native frame: IP = FFFFFC7FE7234446, SP = FFFFFC7FFFDFE630 
Processing exception at native frame: IP = FFFFFC7FE72350B7, SP = FFFFFC7FFFDFE650 
Processing exception at native frame: IP = FFFFFC7FE7108414, SP = FFFFFC7FFFDFE6C0 
Processing exception at native frame: IP = FFFFFC7FE73CAA96, SP = FFFFFC7FFFDFE900 
Processing exception at native frame: IP = FFFFFC7FE73CAB64, SP = FFFFFC7FFFDFE920 
Processing exception at native frame: IP = FFFFFC7FE73CABE5, SP = FFFFFC7FFFDFEAA0 
Processing exception at native frame: IP = FFFFFC7FE73CAEAA, SP = FFFFFC7FFFDFEAC0 
Processing exception at native frame: IP = FFFFFC7FE73CB1ED, SP = FFFFFC7FFFDFEB40 
Processing exception at native frame: IP = FFFFFC7FE7103E11, SP = FFFFFC7FFFDFEC20 
Processing exception at native frame: IP = FFFFFC7FE70DF4F1, SP = FFFFFC7FFFDFEED0 
Processing exception at native frame: IP = FFFFFC7FE8222EE4, SP = FFFFFC7FFFDFF050 
Processing exception at native frame: IP = FFFFFC7FE8238FA8, SP = FFFFFC7FFFDFF110 
Processing exception at native frame: IP = FFFFFC7FE823921D, SP = FFFFFC7FFFDFF150 
Processing exception at native frame: IP = FFFFFC7FE8239846, SP = FFFFFC7FFFDFF290 
Processing exception at native frame: IP = FFFFFC7FE862D84C, SP = FFFFFC7FFFDFF2E0 
Processing exception at native frame: IP = FFFFFC7FE862F450, SP = FFFFFC7FFFDFF490 
Processing exception at native frame: IP = FFFFFC7FE8630FB9, SP = FFFFFC7FFFDFF580 
Processing exception at native frame: IP = FFFFFC7FE862F662, SP = FFFFFC7FFFDFF620 
Processing exception at native frame: IP = FFFFFC7FE862ABD9, SP = FFFFFC7FFFDFF6E0 
Processing exception at native frame: IP = 000000000040E33B, SP = FFFFFC7FFFDFF7E0 
Processing exception at native frame: IP = 000000000040E625, SP = FFFFFC7FFFDFF8D0 
Processing exception at native frame: IP = 00000000004031D3, SP = FFFFFC7FFFDFFA70 
Processing exception at native frame: IP = 0000000000403138, SP = FFFFFC7FFFDFFAA0 
returning 0     <-- this one from libunwind 
Processing exception at native frame: IP = 0000000000000000, SP = FFFFFC7FFFDFFAD0
Unhandled exception. System.Exception: Hello exception!
   at test-app.Program.Main(String[] args)
Abort (core dumped)
@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Jun 25, 2020
@am11
Copy link
Member Author

am11 commented Jun 25, 2020

@jasonbking suggested that if it is libunwind misbehaving, it would be helpful to come up with a short repro (preferably in plain C).

@janvorli, is there any such repro available offhand? I am not sure whether to cut off the assembly stubs (RtlCaptureContext and friends) in repro.

@jkotas jkotas added the os-SunOS SunOS, currently not officially supported label Jun 25, 2020
@janvorli
Copy link
Member

The behavior you are seeing is correct. Unhandled exception should exit via abort and it does so on Linux too. This is from my Ubuntu 16.04:

 ~/dotnet50/dotnet /home/janvorli/test/testunhandled/bin/Debug/net5.0/testunhandled.dll --throw
Hello exception!
Unhandled exception. System.Exception: Hello exception!
   at Program.Main(String[] args) in /home/janvorli/test/testunhandled/Program.cs:line 9
Aborted (core dumped)

@am11
Copy link
Member Author

am11 commented Jun 25, 2020

I was testing on Ubuntu 18.04. Although the exit code was 134, wasn't giving Aborted (core dumped). This message comes from shell when an app (bash job) terminates from a signal. e.g. a simple C program produces that in the same shell session:

gcc -xc - <<EOF
#include <stdlib.h>
int main(void)
{
    abort();
    return (0);
}
EOF
./a.out
Aborted (core dumped)

@am11
Copy link
Member Author

am11 commented Jun 25, 2020

Ah, I was doing dotnet run --throw which fork()s, instead of dotnet path/to/file.dll --throw. So it makes sense. :)

@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-ExceptionHandling-coreclr os-SunOS SunOS, currently not officially supported untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

5 participants