Feature Request (for 1.0 as well): add a way to override the GC-perceived top of the stack

downs default_357-line at yahoo.de
Fri Jan 11 08:36:58 PST 2008


The Phobos GC presumes a linear stack that stretches from <bottom> to the current ESP.

This model is normally correct; however, the virtual stacks used in StackThreads or similar
models kinda break it.

>
> Illustration:
>
>   Normal stack:
>
> [bottom]=====================================[ESP]
>
>
>   StackThreads stack:
>
> [bottom]=========|==========[End]   [Heap================================================= ... ]
>                  |
>                  +......................[Virtual stack bottom]====================[ESP]
>

This is easy to fix; introduce a new Thread function (getStackTop) that checks if a Thread member
variable (void *overrideStackTop) is set; if yes, return that variable, otherwise return getESP().

Since this is a rather smallish correction that doesn't require any API change, I'd greatly welcome it
if this change was applied to 1.0, since because of the way the current GC works, writing reliable
StackThreads is essentially impossible.

Thanks for your consideration,

 --downs



More information about the Digitalmars-d mailing list