Bug 49278 - GC uses deprecated runtime API on shutdown
Summary: GC uses deprecated runtime API on shutdown
Alias: None
Product: Runtime
Classification: Mono
Component: GC ()
Version: master
Hardware: PC Mac OS
: Normal normal
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
Depends on:
Reported: 2016-12-08 07:15 UTC by Rodrigo Kumpera
Modified: 2017-10-06 23:30 UTC (History)
6 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Rodrigo Kumpera 2016-12-08 07:15:38 UTC
In mono_gc_cleanup, we use mono_thread_internal_stop to stop the finalizer thread.

That API is deprecated and is going untested.

We should replace it with a regular thread abort, by calling mono_thread_internal_abort.

To write a test case for this try the following:

Allocate objects with finalizers that take a long time (sleep, loops, etc).
Force a GC so those objects get in the finalizer queue.
Leave the main thread, triggering shutdown.
Ensure with CWLs and busy looping from the main thread, that we only leave it when finalization started.
Comment 1 Rodrigo Kumpera 2016-12-08 07:17:09 UTC
Hey guys,

This is a nice to have cleanup that would allow us to remove the last remaining user of thread stop, which is a very broken variant of thread abort.
Comment 2 Zoltan Varga 2016-12-17 09:54:29 UTC
We already abort the thread, the stop is done when the abort fails. _stop () is somewhat guaranteed to succeed.