cygthread::cygthread() hang

Christopher Faylor
Wed Apr 9 16:56:00 GMT 2003

On Wed, Apr 09, 2003 at 12:31:58PM -0400, Joe Buehler wrote:
>Christopher Faylor wrote:
>>Yep.  I guess it's possible that there are more leaks than just the
>>stack one.
>OK, I think I know what is going on.  The stack address for terminated
>threads is walking up through memory until it hits the top and then
>CreateThread() fails.  So the thread stack is not being freed.
>Looking at the API documentation, it looks like VirtualFree() is not being
>used correctly.  The VirtualQuery() function is returning a region of size
>4096.  So probably that is all that is committed, the rest is reserved,
>and VirtualFree is only freeing the committed memory, since everything has
>to be in the same state.  I'll call VirtualFree() twice like the docs say
>and see if that fixes it.

It's entirely possible that the stack size is only 4096, though.  However,
each allocation of a stack also set aside a guard page, so it sounds like
the guard page isn't being freed.  Nice catch.


More information about the Cygwin-developers mailing list