|
@@ -737,7 +737,13 @@ BEGIN_CP_FUNC(running_thread)
|
|
|
if (thread->shim_tcb) {
|
|
|
ptr_t toff = ADD_CP_OFFSET(sizeof(shim_tcb_t));
|
|
|
new_thread->shim_tcb = (void *)(base + toff);
|
|
|
- memcpy(new_thread->shim_tcb, thread->shim_tcb, sizeof(shim_tcb_t));
|
|
|
+ struct shim_tcb* new_tcb = new_thread->shim_tcb;
|
|
|
+ memcpy(new_tcb, thread->shim_tcb, sizeof(*new_tcb));
|
|
|
+ /* don't export stale pointers */
|
|
|
+ new_tcb->self = NULL;
|
|
|
+ new_tcb->tp = NULL;
|
|
|
+ new_tcb->context.next = NULL;
|
|
|
+ new_tcb->debug_buf = NULL;
|
|
|
}
|
|
|
}
|
|
|
END_CP_FUNC(running_thread)
|
|
@@ -752,6 +758,7 @@ static int resume_wrapper (void * param)
|
|
|
shim_tcb_init();
|
|
|
shim_tcb_t* saved_tcb = thread->shim_tcb;
|
|
|
assert(saved_tcb->context.regs && saved_tcb->context.regs->rsp);
|
|
|
+ set_cur_thread(thread);
|
|
|
unsigned long fs_base = saved_tcb->context.fs_base;
|
|
|
assert(fs_base);
|
|
|
init_fs_base(fs_base, thread);
|
|
@@ -805,6 +812,7 @@ BEGIN_RS_FUNC(running_thread)
|
|
|
shim_tcb_t* tcb = shim_get_tcb();
|
|
|
memcpy(tcb, saved_tcb, sizeof(*tcb));
|
|
|
__shim_tcb_init(tcb);
|
|
|
+ set_cur_thread(thread);
|
|
|
|
|
|
assert(tcb->context.regs && tcb->context.regs->rsp);
|
|
|
init_fs_base(tcb->context.fs_base, thread);
|
|
@@ -822,9 +830,8 @@ BEGIN_RS_FUNC(running_thread)
|
|
|
* shim_tcb = NULL
|
|
|
* in_vm = false
|
|
|
*/
|
|
|
- thread->shim_tcb = shim_get_tcb();
|
|
|
- debug_setbuf(thread->shim_tcb, false);
|
|
|
set_cur_thread(thread);
|
|
|
+ debug_setbuf(thread->shim_tcb, false);
|
|
|
}
|
|
|
|
|
|
thread->in_vm = thread->is_alive = true;
|