Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subject<T> stops publishing items

I have a Subject<T> that I'm publishing items into via OnNext and after a while, under load, I get this exception:

System.NullReferenceException: Object reference not set to an instance of an object
at System.Diagnostics.ExceptionExtensions.PrepareForRethrow (System.Exception exception) [0x00000] in <filename unknown>:0
at System.Concurrency.AsyncLock.Wait (System.Action action) [0x00000] in <filename unknown>:0
at System.Concurrency.Scheduler+<>c__DisplayClass4.<Schedule>b__0 () [0x00000] in <filename unknown>:0
at System.Concurrency.ImmediateScheduler.Schedule (System.Action action) [0x00000] in <filename unknown>:0
at System.Concurrency.Scheduler.Schedule (IScheduler scheduler, System.Action`1 action) [0x00000] in <filename unknown>:0
at System.ScheduledObserver`1[GetNotifyd.Superfeedr.FeedItem].EnsureActive () [0x00000] in <filename unknown>:0
at System.Collections.Generic.Subject`1[GetNotifyd.Superfeedr.FeedItem].OnNext (GetNotifyd.Superfeedr.FeedItem value) [0x00000] in <filename unknown>:0

After this happens I can still publish items via OnNext, but my subscriber no longer receives anything. This is running under mono 2.10.1 using the .NET 3.5 Reactive Extensions DLLs from MS (i.e. i don't think it's mono code that's dying). I haven't seen this happen when I try it on windows, but i haven't run the same loads there. The item that is the argument to OnNext is definitely not null, so that's not the cause.

Any idea what might be causing this or how i could recover the Subject, or do i just have to create a new Subject, notify all my subscribers to subscribe to that instead?

Since it looks like an Rx issue, i've also reported it on their forum

Update: The issue was confirmed as a Rx/mono issue for the combinations of versions i was using. Upgrading to latest Rx (1.0.10605) fixed the problem.

like image 451
Arne Claassen Avatar asked May 22 '26 21:05

Arne Claassen


1 Answers

You might be hitting a race condition bug in Rx.

Notice in this MSDN thread, a poster had a similar problem: an unexplained NullReferenceException coming from a stack trace that hits AsyncLock.Wait.

Now, his problem was caused by [ThreadStatic] not working on the Windows Phone 7. Is it possible [ThreadStatic] has nuanced behavior on Mono?

I'd recommend reporting this error to the Rx team via the Rx forums.

like image 184
Judah Gabriel Himango Avatar answered May 24 '26 09:05

Judah Gabriel Himango



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!