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

[Bug]: LockRecursionException: Recursive read lock acquisitions not allowed in this mode #3932

Closed
dmalukov opened this issue Nov 13, 2024 · 3 comments
Labels

Comments

@dmalukov
Copy link

dmalukov commented Nov 13, 2024

Describe the bug 🐞

During one of nightly stress tests our app got crashed with the following exception.
It's not clear what exactly happened and how to reproduce it.

System.Threading.LockRecursionException: Recursive read lock acquisitions not allowed in this mode.
   at System.Threading.ReaderWriterLockSlim.TryEnterReadLockCore(TimeoutTracker timeout)
   at WinRT.Cache.Create(IObjectReference obj, Int32 index, WeakReference`1 state)
   at WinRT.EventSource`1.Subscribe(TDelegate del)
   at System.Reactive.Concurrency.DispatcherQueueScheduler.ScheduleSlow[TState](TState state, TimeSpan dueTime, Func`3 action) in /_/src/ReactiveUI.Maui/WinUI/DispatcherQueueScheduler.cs:line 129
   at System.Reactive.Concurrency.DispatcherQueueScheduler.Schedule[TState](TState state, TimeSpan dueTime, Func`3 action) in /_/src/ReactiveUI.Maui/WinUI/DispatcherQueueScheduler.cs:line 109
   at System.Reactive.Concurrency.Scheduler.ScheduleAction[TState](IScheduler scheduler, TState state, TimeSpan dueTime, Action`1 action)
   at System.Reactive.Concurrency.Scheduler.SchedulePeriodicRecursive`1.Tick(Int32 command, Action`2 recurse)
   at System.Reactive.Concurrency.Scheduler.<>c__78`1.<ScheduleAction>b__78_0(IScheduler _, ValueTuple`2 tuple)
   at System.Reactive.Concurrency.DispatcherQueueScheduler.<>c__DisplayClass12_0`1.<ScheduleSlow>b__0(DispatcherQueueTimer s, Object e) in /_/src/ReactiveUI.Maui/WinUI/DispatcherQueueScheduler.cs:line 131
   at ABI.Windows.Foundation.TypedEventHandler`2.Do_Abi_Invoke[TSenderAbi,TResultAbi](Void* thisPtr, TSenderAbi sender, TResultAbi args)

We have a crash dump with a $stowedexception, so if it may be useful, we can share it with you.

Reproduction repository

https://github.com/reactiveui/ReactiveUI

IDE

Visual Studio 2022

Operating system

Windows 10 x64

ReactiveUI Version

ReactiveUI.WinUI 21.1.1

@dmalukov dmalukov added the bug label Nov 13, 2024
@ChrisPulman
Copy link
Member

Please could you provide a Repo demonstrating this issue, it looks like there is an async lock involved but without knowledge of the code execution will be hard to trace with purely this exception. We the ReactiveUI code base does not use a ReaderWriterLockSlim component, but it may exist in another project either as a base library or an extension within the ReactiveUI group.
Please provide more information on this.

@dmalukov
Copy link
Author

dmalukov commented Feb 10, 2025

Unfortunately, there is no repro for this issue.
It's a random crash and I no longer have complaints about it.

I don't think other extensions/libraries are involved here.

Apparently, DispatcherQueueScheduler, belonging to ReactiveUI.WinUI package, called subscribe on event, which under the hood calls Create method of EventSourceCache which triggers the exception.
ReaderWriterLockSlim is a field of the EventSourceCache.

So, If you think this problem is not related to the ReactiveUI, feel free to close the ticket.

@glennawatson
Copy link
Contributor

Will close it, but feel free to open a new bug if it happens again. One of those hard to debug ones.

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

No branches or pull requests

3 participants