illumos-joyent
illumos-joyent copied to clipboard
LX: .NET Core 2 segfaults when handling exceptions
Steps to reproduce in LX:
- Install .NET Core 2.1.4
-
git clone https://github.com/AustinWise/CrashRepro.git
-
cd CrashRepro/csharp
-
dotnet run
The reproduction program is boiled down from the /Accounts/Login page generated by dotnet new mvc --auth Individual
. On Linux the NullReferenceExceptions are caught just fine. On LX, the program segfaults while processing the second exception.
The root cause of the crash is a difference in how LX and Linux select the stack to run a signal handler on for a signal that has been configured using sigaltstack(2)
. If the signal handler changes its stack pointer to different location outside of the alternate stack, unmasks the signal, and triggers the signal again before returning from the signal handler, Linux starts executing the nested signal handler at the start of the alternate stack. LX notices that the signal handler never returned and does not use the alternate stack.
In the c directory of the same repo, there is a C program that can detect this difference in stack handling. In the root of the repo there is a README with more details on how this difference in signal behavior causes the crash.
I have a fork of illumos-joyent with a potential fix for the problem. I'm not sure if this is the right way to fix this problem, but it does make .NET Core's exception handling work for me.
This is fixed in .NET Core 3.0 by dotnet/coreclr#25196.