Skip to content

Method for finding cold end of stack needs justification #210

@rptb1

Description

@rptb1

The manual advises the use of a stack marker to find the cold end of the stack:

void *marker = ▮
mps_root_t stack_root;
res = mps_root_create_thread(&stack_root, arena, thread, marker);
if (res != MPS_RES_OK) error("Couldn't create stack root");
In order to scan the control stack, the MPS needs to know where the
:term:`cold end` of the stack is, and that's the role of the
:c:data:`marker` variable: the compiler places it on the stack, so its
address is a position within the stack. As long as you don't exit from
this function while the MPS is running, your program's active local
variables will always be placed on the stack after :c:data:`marker`,
and so will be scanned for references by the MPS.

Is this advice reliable with current compiler optimisations on our target platforms?

We should check and record our justification for it. We should also test for it, for example, by asserting about it in our tests, so that we are warned if it ever becomes false.

Incidentally, on this topic, design.mps.stack-scan.req.stack.cold.not says:

_`.req.stack.cold.not`: There is no requirement to locate the cold end
of the stack. (The mutator supplies this as an argument to
``mps_root_create_thread()``.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationneeds analaysisThe issue needs analysis before it can be resolved.optionalWill cause failures / of benefit. Worth assigning resources.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions