runtime: dotnet core application aborts without exceptions
@pavlexander commented on Wed Feb 14 2018
Issue Title
.net core 2 console application stops execution and quits without providing any kind of exception messages, except short notice “Aborted”
General
The issue is only reproducible on Linux, but not Windows.
System:
- Linux: Debian 9, x64 bits
- dotnet --version: 2.1.3
- compiled on Windows 10 x64 with command: dotnet publish -c release -r debian-x64
- thread on StackoverFlow
- bug report on git
Description
During the deserialization (or initialization) of objects of a certain type - application crashes on Linux environment immediately.
A sample code for issue reproduction is:
static void Main(string[] args)
{
var symbol = Symbol.ONE;
// if real library is used then Symbol.BNB_BTC or (Symbol)"BNBBTC" will do
}
The Symbol
class is implemented with a type-safe Enum pattern:
public sealed class Symbol
{
public static readonly Symbol ONE = new Symbol(new[] { OrderType.Limit, OrderType.LimitMaker, OrderType.Market, OrderType.StopLossLimit, OrderType.TakeProfitLimit });
public static readonly Symbol TWO = new Symbol(new[] { OrderType.Limit, OrderType.LimitMaker, OrderType.Market, OrderType.StopLossLimit, OrderType.TakeProfitLimit });
public static readonly Symbol THREE = new Symbol(new[] { OrderType.Limit, OrderType.LimitMaker, OrderType.Market, OrderType.StopLossLimit, OrderType.TakeProfitLimit });
// 264 such lines in total
public Symbol(IEnumerable<OrderType> orderTypes)
{
}
}
In the example above, upon initialization of Symbol
type object - application would abort at rate 1/5 (or more often/rarely):
Testing
while sleep 0.5 ; do dotnet ConsoleApp1.dll ; done
The linux command will execute dotnet application once in half-a-second time. Therefore, if at least one “Aborted” is printed within 20 second interval - you can consider the test as not passed.
Fix
I was able to come up with a temporary solution which seems to be working at the moment.
If we change an anonymous type of object in constructor parameter list to List
- then that will work nicely.
Instead of this:
new[] { OrderType.Limit, OrderType.LimitMaker, OrderType.Market, OrderType.StopLossLimit, OrderType.TakeProfitLimit }
use this:
new List<OrderType> { OrderType.Limit, OrderType.LimitMaker, OrderType.Market, OrderType.StopLossLimit, OrderType.TakeProfitLimit }
Also, it was confirmed, that OrderType[]
type of object yields absolutely the same result as new[]
Also, it was confirmed (on my machine), that if the number of static properties is halved, then the issue is gone, therefore, for better effect - test the solution when more than 200 Symbol
s are defined in Symbol
class.
Steps to reproduce
The easiest steps to reproduce the issue is to:
- Download the same library as I did here.
- Change the source for the
Symbol
class, so that anonymous object is used (author recently applied a fix, per my request) - add new console application (see description section)
- compile and then run on Linux (see testing section)
If you see the “Aborted” message after some time, then that’s the issue.
Suggested fix
I would appreciate to
- see some kind of exception message when such errors are thrown
- issue to be fixed
Rest is up to you. Good luck.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 67 (34 by maintainers)
@pavlexander I was able to repro the issue in a VM with a fresh install of debian 9.3 So I can finally debug it.
@pavlexander even release build is supposed to be debuggable, the difference is just whether optimizations are applied or not.