[Gc] Re: [Fwd: [PATCH] Fix boehm-gc build on Cygwin]

Dave Korn dave.korn.cygwin at googlemail.com
Tue May 19 06:50:33 PDT 2009

Ivan Maidanski wrote:
> Hi!
> "Boehm, Hans" <hans.boehm at hp.com> wrote:
>> Unless someone can think of a reason this is silly, I'll check the
>> following into the upstream sources, so that we at least don't lose the
>> code.  I suspect that what we currently do is worse.
> It seems that You're right. At least, it seems it removes "Thread stack
> pointer ... out of range, pushing everything" warning (in case of

  Just to explain how it works: the %fs segment in windows always points to a
block of thread-specific data called "struct NT_TIB" that contains pointers to
the stack limits for the thread.


  Note that that description is a bit confusing, it uses "Top" of stack to
mean the highest memory end and "Bottom" to describe the moving lowest memory
end pointed to by $esp[*]

  The reason for the references to TLS in the code is because it is modelled
on the code from the Cygwin DLL that locates the TLS area, which Cygwin
maintains in memory just above the high end of the stack.

[ or https://tinyurl.com/how-cygtls-works to avoid wrapping ]

  So, the value returned is exactly one byte after the highest byte of the
stack, i.e. if the stack is located in the 64k page from 0x220000 to 0x22ffff
then the return value is 0x230000.  I wasn't sure whether to subtract one or
not, I'm sure you guys will know whether that's the right thing to do.  (I
figured it probably wouldn't matter for the purposes of bounds-checking
whether something came from the stack or not anyway.)

[*] - as opposed to the sense in which the top of the stack is the place where
you push stuff onto and pop stuff off of meaning the lowest memory end and the
bottom of the stack is the base where it all started meaning the highest
memory end.

More information about the Gc mailing list