[Mono-bugs] [Bug 678662] New: Exception "invalid handle specified" because mono_thread_pool_cleanup() is called twice

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Mar 10 14:12:12 EST 2011



           Summary: Exception "invalid handle specified" because
                    mono_thread_pool_cleanup() is called twice
    Classification: Mono
           Product: Mono: Runtime
           Version: 2.10.x
          Platform: All
        OS/Version: Windows 7
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: misc
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: horst at kakuschke.de
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:
Gecko/20110303 Firefox/3.6.15

While debugging another problem in Visual Studio under Windows I got an
exception "An invalid handle was specified" while running mono.exe .

Problem here is that mono_main() calls mono_thread_pool_cleanup() twice:
(1) mono_main() => mono_thread_manage() => mono_thread_pool_cleanup()
(2) mono_main() => mini_cleanup() => mono_domain_finalize() =>

mono_thread_pool_cleanup() does MONO_SEM_DESTROY (&async_io_tp.new_job), and on
the second call the handle is already freed resulting in an exception.

A "quick fix" would be to set async_io_tp.new_job to zero after freeing and
testing it before freeing again.

This would be in mono_semaphore.h :
- #    define MONO_SEM_DESTROY(sem) CloseHandle (*(sem))
+ #    define MONO_SEM_DESTROY(sem) if (*sem != 0) { CloseHandle (*(sem)); *sem
= 0; 

Reproducible: Always

Steps to Reproduce:
Execute any assembly with debug version of mono.exe built with Visual Studio
under Windows.
Actual Results:  
Exception at 0x77d3708f in mono.exe: An invalid handle was specified.

Expected Results:  
No exception ;-)

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.

More information about the mono-bugs mailing list