Re: [Mono-list] Patch for GC_stop_world bug in Android apps
I think I sent this email to the wrong list. Sorry for the duplicate: Hey guys, thanks for taking my earlier patch that fixes garbage collection in multithreaded apps! Debugging threads on Android is currently broken due to the same underlying issue. Currently the debugger will exhibit some very strange behavior when attempting to debug a thread, and eventually hang the process. I was able to reproduce the same problem in my parallel project which I've been maintaining. Here is the patch to fix the debugger agent (and another pthread_kill related issue which I haven't been able to find a bug for yet): http://github.com/koush/mono/commit/aec2389f485a271606443c6ee3865729c30526a7 Submitted under the terms of the MIT/X11 license. Koush On Fri, Oct 1, 2010 at 9:31 AM, Koushik Dutta ko...@koushikdutta.comwrote: I submit this patch under the terms of the MIT/X11 license On Fri, Oct 1, 2010 at 7:12 AM, Geoff Norton gnor...@novell.com wrote: Koush, Nice, can you please confirm on the list that you're willing to contribute this patch under the terms of the MIT/X11 license? Thanks -g On 2010-09-30, at 12:26 AM, Koushik Dutta wrote: Here is the fix for the following bug: https://bugzilla.novell.com/show_bug.cgi?id=633454 The underlying problem is there is a bug in Android's libc, where after a process forks, the kernel id of the forked thread is not changed to reflect the new child thread. The pthread kernel id still points to the kernel id of the parent process: zygote. This bug breaks all multithread monodroid apps (as well as my mono on Android port), as Garbage Collection fails and the process hangs. The fix/workaround for the bug in Android is as follows: The GC_Thread structure on Android has a new kernel_id member. When GC_new_thread is called, the kernel id is also retrieved and stored with gettid. When the world needs to be stopped/started, a new function android_thread_kill is called, which is a reimplementation of Android's pthread_kill. Instead, which takes the correct kernel id, rather than the potentially hosed pthread. I have attached a patch file, as well as committed to my fork of mono on Github: http://github.com/koush/mono/commit/414aff5598a2dea618741bea714fa8dd1baf0d52 pthread_android.patch___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
Re: [Mono-list] Patch for GC_stop_world bug in Android apps
Koush, Nice, can you please confirm on the list that you're willing to contribute this patch under the terms of the MIT/X11 license? Thanks -g On 2010-09-30, at 12:26 AM, Koushik Dutta wrote: Here is the fix for the following bug: https://bugzilla.novell.com/show_bug.cgi?id=633454 The underlying problem is there is a bug in Android's libc, where after a process forks, the kernel id of the forked thread is not changed to reflect the new child thread. The pthread kernel id still points to the kernel id of the parent process: zygote. This bug breaks all multithread monodroid apps (as well as my mono on Android port), as Garbage Collection fails and the process hangs. The fix/workaround for the bug in Android is as follows: The GC_Thread structure on Android has a new kernel_id member. When GC_new_thread is called, the kernel id is also retrieved and stored with gettid. When the world needs to be stopped/started, a new function android_thread_kill is called, which is a reimplementation of Android's pthread_kill. Instead, which takes the correct kernel id, rather than the potentially hosed pthread. I have attached a patch file, as well as committed to my fork of mono on Github: http://github.com/koush/mono/commit/414aff5598a2dea618741bea714fa8dd1baf0d52 pthread_android.patch___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
Re: [Mono-list] Patch for GC_stop_world bug in Android apps
I submit this patch under the terms of the MIT/X11 license On Fri, Oct 1, 2010 at 7:12 AM, Geoff Norton gnor...@novell.com wrote: Koush, Nice, can you please confirm on the list that you're willing to contribute this patch under the terms of the MIT/X11 license? Thanks -g On 2010-09-30, at 12:26 AM, Koushik Dutta wrote: Here is the fix for the following bug: https://bugzilla.novell.com/show_bug.cgi?id=633454 The underlying problem is there is a bug in Android's libc, where after a process forks, the kernel id of the forked thread is not changed to reflect the new child thread. The pthread kernel id still points to the kernel id of the parent process: zygote. This bug breaks all multithread monodroid apps (as well as my mono on Android port), as Garbage Collection fails and the process hangs. The fix/workaround for the bug in Android is as follows: The GC_Thread structure on Android has a new kernel_id member. When GC_new_thread is called, the kernel id is also retrieved and stored with gettid. When the world needs to be stopped/started, a new function android_thread_kill is called, which is a reimplementation of Android's pthread_kill. Instead, which takes the correct kernel id, rather than the potentially hosed pthread. I have attached a patch file, as well as committed to my fork of mono on Github: http://github.com/koush/mono/commit/414aff5598a2dea618741bea714fa8dd1baf0d52 pthread_android.patch___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
Re: [Mono-list] Patch for GC_stop_world bug in Android apps
Great thanks, commited to master. -g On 2010-10-01, at 12:31 PM, Koushik Dutta wrote: I submit this patch under the terms of the MIT/X11 license On Fri, Oct 1, 2010 at 7:12 AM, Geoff Norton gnor...@novell.com wrote: Koush, Nice, can you please confirm on the list that you're willing to contribute this patch under the terms of the MIT/X11 license? Thanks -g On 2010-09-30, at 12:26 AM, Koushik Dutta wrote: Here is the fix for the following bug: https://bugzilla.novell.com/show_bug.cgi?id=633454 The underlying problem is there is a bug in Android's libc, where after a process forks, the kernel id of the forked thread is not changed to reflect the new child thread. The pthread kernel id still points to the kernel id of the parent process: zygote. This bug breaks all multithread monodroid apps (as well as my mono on Android port), as Garbage Collection fails and the process hangs. The fix/workaround for the bug in Android is as follows: The GC_Thread structure on Android has a new kernel_id member. When GC_new_thread is called, the kernel id is also retrieved and stored with gettid. When the world needs to be stopped/started, a new function android_thread_kill is called, which is a reimplementation of Android's pthread_kill. Instead, which takes the correct kernel id, rather than the potentially hosed pthread. I have attached a patch file, as well as committed to my fork of mono on Github: http://github.com/koush/mono/commit/414aff5598a2dea618741bea714fa8dd1baf0d52 pthread_android.patch___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Patch for GC_stop_world bug in Android apps
Here is the fix for the following bug: https://bugzilla.novell.com/show_bug.cgi?id=633454 The underlying problem is there is a bug in Android's libc, where after a process forks, the kernel id of the forked thread is not changed to reflect the new child thread. The pthread kernel id still points to the kernel id of the parent process: zygote. This bug breaks all multithread monodroid apps (as well as my mono on Android port), as Garbage Collection fails and the process hangs. The fix/workaround for the bug in Android is as follows: The GC_Thread structure on Android has a new kernel_id member. When GC_new_thread is called, the kernel id is also retrieved and stored with gettid. When the world needs to be stopped/started, a new function android_thread_kill is called, which is a reimplementation of Android's pthread_kill. Instead, which takes the correct kernel id, rather than the potentially hosed pthread. I have attached a patch file, as well as committed to my fork of mono on Github: http://github.com/koush/mono/commit/414aff5598a2dea618741bea714fa8dd1baf0d52 pthread_android.patch Description: Binary data ___ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list