[Mono-dev] Multiple disposal

Neale Ferguson neale at sinenomine.net
Thu Apr 19 15:58:21 UTC 2018


I am making progress with my openssl TLS provider such that it’s actually making calls etc. However, when things are closing down I am getting an object being disposed of multiple times from different places. The X509 context object is being disposed of. The first time the sequence of calls is show in:

https://pastebin.com/jWrzfd2P

The disposal will null the handle:


                protected void Dispose (bool disposing)

                {

                        if (disposing) {

                                try {

                                        if (handle != null) {

                                                Close ();

                                                handle.Dispose ();

                                                handle = null;

                                        }

                                } finally {

                                        var disposedExc = new ObjectDisposedException (GetType ().Name);

                                        Interlocked.CompareExchange (ref lastError, disposedExc, null);

                                }

                        }

                }

But then Dispose is called via this sequence:

https://pastebin.com/qAeXdrLd

And, lo & behold, the value of handle is exactly the same (and not null). I have verified that a new handle had not been created. The openssl code is almost identical to the btls code (it is identical if you ignore naming of variables and methods).

This code was cloned from master on Wednesday afternoon.

Neale




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dot.net/pipermail/mono-devel-list/attachments/20180419/23f048d3/attachment.html>


More information about the Mono-devel-list mailing list