mono_debug_init is a public embedding interface and calls into
mono_debugger_initialize, which registers a GC root. driver.c calls
mono_gc_base_init before calling mono_debug_init for this reason, but
that's not an option for embedding (as mono_gc_base_init is internal.)
since mono_gc_base_init is idempotent, just add a call to
mono_debug_init (and remove the driver.c call). Document (in sgen-gc
and sgen-gc.h) the fact that although mono_gc_base_init is idempotent,
changing LOCK_INIT to something non-idempotent will break this.
mono_debug_initialized = TRUE;
mono_debug_format = format;
+ /*
+ * This must be called before mono_debugger_initialize(), because the
+ * latter registers GC roots.
+ */
+ mono_gc_base_init ();
+
mono_debugger_initialize (_mono_debug_using_mono_debugger);
mono_debugger_lock ();
char *major_collector = NULL;
struct sigaction sinfo;
+ /* the gc_initialized guard seems to imply this method is
+ idempotent, but LOCK_INIT(gc_mutex) might not be. It's
+ defined in sgen-gc.h as nothing, so there's no danger at
+ present. */
LOCK_INIT (gc_mutex);
LOCK_GC;
if (gc_initialized) {
* Recursion is not allowed for the thread lock.
*/
#define LOCK_DECLARE(name) pthread_mutex_t name = PTHREAD_MUTEX_INITIALIZER
+/* if changing LOCK_INIT to something that isn't idempotent, look at
+ its use in mono_gc_base_init in sgen-gc.c */
#define LOCK_INIT(name)
#define LOCK_GC pthread_mutex_lock (&gc_mutex)
#define UNLOCK_GC pthread_mutex_unlock (&gc_mutex)
}
#endif
- /*
- * This must be called before mono_debug_init(), because the
- * latter registers GC roots.
- */
- mono_gc_base_init ();
-
if (action == DO_DEBUGGER) {
enable_debugging = TRUE;