-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Description
lock/Monitor supports recursion but does not seem to document or enforce a limit.
Right now it uses the object header up to 64 or so, then transitions to a sync block. That uses a 64 bit counter.
Correctness wise, it looks like the counter will just wrap (and release?) if code hits the limit -- given the size the chance of this is basically zero though.
But it might be interesting to pick a maximum recursion count that is less than ulong.MaxValue but greater than any plausible functioning code would need, then throw LockRecursionException when it's hit. This would expose any buggy code that is recursing without bound.
cc @kouvel from #34812 (comment)
kouvel