[Gc] Back to "GC Stack problem on Win32"

Ivan Maidanski ivmai at mail.ru
Sat Nov 1 04:46:50 PST 2008


"Boehm, Hans" <hans.boehm at hp.com wrote a week ago:
> Thanks.
> I finally checked in the attached patch, which is loosely based on yours.  I retained the simpler interface for GC_get_stack_min, but added GC_may_be_in_stack as a separate function.  I also simplified GC_get_next_stack.  And I think the thread pushing code could fail for more cases than the original, so I changed that, too.  I think the basic algorithm is the same as what you had.
> So far, this has only been minimally tested under Cygwin.  I'd appreciate if someone could test more thoroughly, and verify that it also still solves the original problem. 

I've already pointed out some bugs.
Now I've just run the same test (having Your patch applied) as I had run for my patch... And it turns out that Yours doesn't solve the problem as it was originally stated (to say more precisely, it doesn't reduce time for the first collection after stack growth).

Look into the things You had advised me before:
> 1) Initially call VirtualQuery on the sp.  If the stack base is in the same region, we know we're OK, and don't need GC_get_stack_min.  Hopefully this will be true about 100% of the time.

So I did it for Your code now. It works.

The patch is attached.


-------------- next part --------------
diff -ru bdwgc/win32_threads.c updated/bdwgc/win32_threads.c
--- bdwgc/win32_threads.c	2008-10-30 23:01:46.000000000 +0300
+++ updated/bdwgc/win32_threads.c	2008-11-01 15:06:12.000000000 +0300
@@ -949,7 +949,10 @@
 	  stack_min = GC_get_stack_min(thread -> stack_base);
 #       else
           if (GC_may_be_in_stack(thread -> last_stack_min)) {
-            stack_min = GC_get_stack_min(thread -> last_stack_min);
+	    stack_min = last_info.BaseAddress;
+	    /* Do not probe rest of the stack if sp is correct. */
+	    if (sp < stack_min || sp >= thread->stack_base)
+	      stack_min = GC_get_stack_min(thread -> last_stack_min);
 	  } else {
 	    stack_min = GC_get_stack_min(thread -> stack_base);

More information about the Gc mailing list