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

LX: .NET Core 2 segfaults when handling exceptions #163

Open
AustinWise opened this issue Mar 12, 2018 · 1 comment
Open

LX: .NET Core 2 segfaults when handling exceptions #163

AustinWise opened this issue Mar 12, 2018 · 1 comment

Comments

@AustinWise
Copy link

AustinWise commented Mar 12, 2018

Steps to reproduce in LX:

  1. Install .NET Core 2.1.4
  2. git clone https://github.com/AustinWise/CrashRepro.git
  3. cd CrashRepro/csharp
  4. 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.

AustinWise added a commit to AustinWise/illumos-joyent that referenced this issue Mar 12, 2018
AustinWise added a commit to AustinWise/illumos-joyent that referenced this issue Mar 16, 2018
@AustinWise
Copy link
Author

This is fixed in .NET Core 3.0 by dotnet/coreclr#25196.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant