From 0140f21cc4ece26330567248b7c5207c8eb197e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6llner?= Date: Sun, 25 Aug 2019 16:33:28 +0200 Subject: [PATCH] Troubleshooting ReleaseOnCancelClient --- Capnp.Net.Runtime/Rpc/RefCountingCapability.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Capnp.Net.Runtime/Rpc/RefCountingCapability.cs b/Capnp.Net.Runtime/Rpc/RefCountingCapability.cs index b620a8f..61faf4b 100644 --- a/Capnp.Net.Runtime/Rpc/RefCountingCapability.cs +++ b/Capnp.Net.Runtime/Rpc/RefCountingCapability.cs @@ -23,6 +23,7 @@ namespace Capnp.Rpc // In order to distinguish state A from C, the member _refCount stores the reference count *plus one*. // Value 0 has the special meaning of being in state C. int _refCount = 1; + string _disposerStackTrace; ~RefCountingCapability() { @@ -68,7 +69,7 @@ namespace Capnp.Rpc { if (Interlocked.Increment(ref _refCount) <= 1) { - throw new ObjectDisposedException(nameof(ConsumedCapability)); + throw new ObjectDisposedException(nameof(ConsumedCapability), _disposerStackTrace); } } @@ -76,6 +77,8 @@ namespace Capnp.Rpc { if (1 >= Interlocked.Decrement(ref _refCount)) { + _disposerStackTrace = Environment.StackTrace; + Dispose(true); GC.SuppressFinalize(this); }