]> granicus.if.org Git - gc/commitdiff
Test SP obtained from OpenBSD-specific pthread context in GC_suspend_all
authorIvan Maidanski <ivmai@mail.ru>
Fri, 20 Jul 2012 11:27:54 +0000 (15:27 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 20 Jul 2012 11:27:54 +0000 (15:27 +0400)
* pthread_stop_world.c (GC_suspend_all): Abort if stop_info.stack_ptr
obtained from OpenBSD-specific pthread context is NULL; add FIXME for
GC_OPENBSD_THREADS case (the implementation should probably use
pthread_sp_np).

pthread_stop_world.c

index 722183527c2307202da72a91c925719977c2c6e8..52573dbdac129d7d1fa8f6a20b3dacf80e6a1007 100644 (file)
@@ -477,13 +477,15 @@ STATIC int GC_suspend_all(void)
 #           ifdef GC_OPENBSD_THREADS
               if (pthread_suspend_np(p -> id) != 0)
                 ABORT("pthread_suspend_np failed");
-              /* This will only work for userland pthreads.  It will    */
-              /* fail badly on rthreads.  Perhaps we should consider    */
-              /* a pthread_sp_np() function that returns the stack      */
+              /* FIXME: This will only work for userland pthreads.      */
+              /* It will fail badly on rthreads.  Perhaps we should     */
+              /* consider pthread_sp_np() that returns the stack        */
               /* pointer for a suspended thread and implement in both   */
               /* pthreads and rthreads.                                 */
               p -> stop_info.stack_ptr =
                         *(ptr_t *)((char *)p -> id + UTHREAD_SP_OFFSET);
+              if (p -> stop_info.stack_ptr == NULL)
+                ABORT("NULL pointer at pthread_context UTHREAD_SP_OFFSET");
 #           else
 #             ifndef PLATFORM_ANDROID
                 result = pthread_kill(p -> id, GC_sig_suspend);