https://bugzilla.novell.com/show_bug.cgi?id=678164
https://bugzilla.novell.com/show_bug.cgi?id=678164#c0 Summary: Threads started by native code that call into managed code get IsBackground==False Classification: Mono Product: Mono: Runtime Version: 2.6.x Platform: x86 OS/Version: Ubuntu Status: NEW Severity: Normal Priority: P5 - None Component: misc AssignedTo: [email protected] ReportedBy: [email protected] QAContact: [email protected] Found By: --- Blocker: --- Created an attachment (id=418332) --> (http://bugzilla.novell.com/attachment.cgi?id=418332) Archive of source for native shared library and managed assembly that demonstrate issue User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.107 Safari/534.13 On Windows using the Microsoft compiler and runtime, if I P/Invoke native code and pass it a delegate (marshalled to a function pointer) and then the native code spawns a thread and invokes the callback on the thread, the managed Thread object created for the thread has IsBackground set to True. Later on, when my main managed thread finishes, the process exits. On Linux using Mono, if I do the same thing, the managed Thread object has IsBackground set to True. If that thread is still running (regardless of whether it is running managed code) when my main managed thread finishes, the process does not exit, but continues to wait for that thread. Reproducible: Always Steps to Reproduce: 1. Build and run the attached code: On Linux with Mono: $ gcc -shared -c native_thread.c -o native_thread.so $ gmcs ThreadTest.cs $ mono ThreadTest.exe False $ On Windows with Microsoft: > cl native_thread.c /LD > csc ThreadTest /platform:x86 > ThreadTest.exe True > 2. It prints out the value of Thread.CurrentThread.IsBackground in the managed callback invoked by the native code on the thread created by the native code. I believe the native libraries are as equivalent and minimal as possible. The Windows one uses CreateThread, the Posix one uses pthreads. Actual Results: In Mono, IsBackground is False. On Windows/.NET, IsBackground is True. Expected Results: I expect IsBackground to be True under Mono as well. This is mostly a problem for our automated tests - when something goes wrong and a test fails we might not be able to cleanly shut down a native library that owns threads. When we try to finish some of the threads created by that library are still running and it appears that Mono hangs waiting for them because it considers them foreground threads. -- 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. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
