[Bug 30864] Mono: Application hangs when calling AppDomain.Unload

wine-bugs at winehq.org wine-bugs at winehq.org
Fri Jun 8 03:10:48 CDT 2012


http://bugs.winehq.org/show_bug.cgi?id=30864

--- Comment #2 from Ivan Voyager <vgr.subscription at gmail.com> 2012-06-08 03:10:48 CDT ---
Mono source: https://github.com/mono/mono

In appdomain.c I found function "mono_domain_try_unload" with potential reason
of hang up:

    /*The managed callback finished successfully, now we start tearing down the
appdomain*/
    domain->state = MONO_APPDOMAIN_UNLOADING;
    /* 
     * First we create a separate thread for unloading, since
     * we might have to abort some threads, including the current one.
     */
    /*
     * If we create a non-suspended thread, the runtime will hang.
     * See:
     * http://bugzilla.ximian.com/show_bug.cgi?id=27663
     */ 
#if 0
    thread_handle = mono_create_thread (NULL, 0, unload_thread_main,
&thread_data, 0, &tid);
#else
    thread_handle = mono_create_thread (NULL, 0,
(LPTHREAD_START_ROUTINE)unload_thread_main, &thread_data, CREATE_SUSPENDED,
&tid);
    if (thread_handle == NULL) {
        return;
    }
    ResumeThread (thread_handle);
#endif

    /* Wait for the thread */    
    while ((res = WaitForSingleObjectEx (thread_handle, INFINITE, TRUE) ==
WAIT_IO_COMPLETION)) {
        if (mono_thread_internal_has_appdomain_ref
(mono_thread_internal_current (), domain) &&
(mono_thread_interruption_requested ())) {
            /* The unload thread tries to abort us */
            /* The icall wrapper will execute the abort */
            CloseHandle (thread_handle);
            return;
        }
    }
    CloseHandle (thread_handle);

Maybe it will be helpful?

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the wine-bugs mailing list