[Gc] Small fix for Win32 GC_push_stack_for

Ivan Maidanski ivmai at mail.ru
Fri Oct 24 04:36:00 PDT 2008


Hi!

This patch removes "Thread stack pointer out of range" warning for the stopped thread with sp just got decremented but not dereferenced yet (i.e. sp points to the guard page of the thread's stack, and, thus, computed stack_min is greater than sp).

Bye.

-------------- next part --------------
diff -ru bdwgc/win32_threads.c updated/bdwgc/win32_threads.c
--- bdwgc/win32_threads.c	2008-10-22 22:24:36.000000000 +0400
+++ updated/bdwgc/win32_threads.c	2008-10-24 15:14:18.372197400 +0400
@@ -962,8 +962,13 @@
 #       endif
         GC_push_all_stack(sp, thread->stack_base);
       } else {
-        WARN("Thread stack pointer 0x%lx out of range, pushing everything\n",
-	     (unsigned long)(size_t)sp);
+	/* If not current thread then it is possible for sp to point to	*/
+	/* the guarded (untouched yet) page just below the current	*/
+	/* stack_min of the thread.					*/
+	if (thread -> id == me || sp >= thread->stack_base
+		|| sp + GC_page_size < stack_min)
+	  WARN("Thread stack pointer 0x%lx out of range, pushing everything\n",
+		(unsigned long)(size_t)sp);
         GC_push_all_stack(stack_min, thread->stack_base);
       }
     } /* thread looks live */


More information about the Gc mailing list