Don't log from the finalizer
RoosterDragon opened this issue · 2 comments
See OpenRA/OpenRA#12450.
We get an unhandled ObjectDisposedException
during our process shutdown. This is because we attach a TraceListener
that writes to a file. The underlying stream gets finalized before your finalizer tries to run and attempts to log.
This would be fixed by simply not logging here.
@RoosterDragon that is not the only line that writes in the log. That's why the fix is not so easy as not logging there.
I have a fix 323587c. It will solve the problem that your users see. Let me know if you find something wrong with it.
I also have a couple of defects to fix before to release a new nuget package version, I hope to be able to do that this week.
I can live with that solution, although it has the downside that if we erroneously passed in an already-disposed logger, instead of getting an exception we now silently won't do any logging. I still think you'd be better of just not logging from finalizers myself.