[Gc] Re: WOW64 bug: GetThreadContext() may return stale contents

Johannes Totz jtotz at imperial.ac.uk
Mon Jan 31 06:35:28 PST 2011


On 21/11/2010 00:04, Henning Makholm wrote:
>>> Just came along this bug report in Microsoft Connect:
>>> http://tinyurl.com/2d9cl4x
>>> Does this affect the Windows version of the collector as well?
> 
>> Probably yes (as ESP of the suspended threads is used to get the stack
>> bounds).
>> Is any workaround suggested for this?
> 
> Apparently not, except for instrumenting all mutator threads with code to
> save their ESP in a place where the GC can find it

Just thinking out loud...

1) GC calls SuspendThread()
2) GC calls GetThreadContext() (or whatever it was called)
3) Get IP, mark page as writable
4) Write jump-instruction to GC-code at IP
5) Resume thread
6) Thread executes part of GC-code that stores ESP to known location
7) Thread restores original instruction, write-protect page
8) Thread suspends itself, and signals GC that ESP is now valid

When GC is done with its work threads resume and jump back to original
location, as if nothing ever happened.


-- 
https://bitbucket.org/jtotz/bdwgc



More information about the Gc mailing list