fix #8551 and make stack switch more efficient

previously, each new stack would have a copy of a small portion of the
stack that started it. in small amounts, this was fine, but it is bad if
the user is starting many tasks. additionally, it wasted memory inside
every task to have a per-task base_ctx.

(cherry picked from commit ac1371136e1aae1ca7366b4d19cc0ffa0d659d72)