Reputation: 1057
We have an REST API running on ASP.NET 5 on Mono and Ubuntu 14.04. We use Mono because we need the NpgSQL driver for a PostgreSQL database.
There is a webserver that is regularly posting data to this API, and a website that can retrieve data from this API.
At first we used Mono 4.2.1, but we got NullReferenceExceptions multiple times a day. So we reverted back to Mono 4.0.5.1, because this article was saying Mono 4.2.1 was buggy.
However, we still get the exception once a day. The full exception is shown here:
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at System.Threading.EventWaitHandle.Reset () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Threading.EventWaitHandle:Reset ()
at System.Threading.Timer+Scheduler.SchedulerThread () [0x00000] in <filename unknown>:0
at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
at System.Threading.EventWaitHandle.Reset () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Threading.EventWaitHandle:Reset ()
at System.Threading.Timer+Scheduler.SchedulerThread () [0x00000] in <filename unknown>:0
at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0
Because the exception still throws on this older version of Mono, I'm thinking it could also be in ASP.NET 5. It does seem to be an issue in the framework itself, because it is in the System.Threading package.
Does anyone have any clue what this is, and what is causing this?
Upvotes: 2
Views: 577
Reputation: 9806
Looks like this bug on xamarin/mono. I'm getting the same issue using Timer
. I'm considering either moving to coreclr from mono (I don't use SQL for this particular project, however Npgsql is available on coreclr in alpha builds).
I'm also going to investigate whether moving to Task
over Timer
is a solution.
This and a number of other posts indicate that a threading issue was fixed in the linux kernel, meaning updating the kernel is a possible fix. Unfortunately that won't work for me because I'm using AWS EC2 HVM instances. I tried switching out the Timer
for Task
s but that doesn't solve it either.
I'm using SignlR .NET Client, which is not compatible with dnxcore50, so that's blocking me from going to the coreclr. I'll update this question if I get any progress on this.
I switched my AWS AMI to Ubuntu, upgraded the kernel, and am no longer getting this error. I updated the kernel to 3.19.0-41-generic
using this process. This, referenced by the original xamarin bug above, suggests it needs to be at a minimum 3.13.0-65
.
Upvotes: 2