diff options
Diffstat (limited to 'src/box64context.c')
| -rw-r--r-- | src/box64context.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/box64context.c b/src/box64context.c index 234657ca..e38d0d33 100644 --- a/src/box64context.c +++ b/src/box64context.c @@ -68,6 +68,8 @@ void free_tlsdatasize(void* p) tlsdatasize_t *data = (tlsdatasize_t*)p; box_free(data->ptr); box_free(p); + if(my_context) + pthread_setspecific(my_context->tlskey, NULL); } void x64Syscall(x64emu_t *emu); @@ -236,7 +238,7 @@ box64context_t *NewBox64Context(int argc) init_mutexes(context); pthread_atfork(NULL, NULL, atfork_child_box64context); - pthread_key_create(&context->tlskey, free_tlsdatasize); + pthread_key_create(&context->tlskey, NULL/*free_tlsdatasize*/); for (int i=0; i<8; ++i) context->canary[i] = 1 + getrand(255); @@ -278,6 +280,7 @@ void FreeBox64Context(box64context_t** context) box64context_t* ctx = *context; // local copy to do the cleanning + //clean_current_emuthread(); // cleaning main thread seems a bad idea if(ctx->local_maplib) FreeLibrarian(&ctx->local_maplib, NULL); if(ctx->maplib) @@ -342,7 +345,6 @@ void FreeBox64Context(box64context_t** context) void* ptr; if ((ptr = pthread_getspecific(ctx->tlskey)) != NULL) { free_tlsdatasize(ptr); - pthread_setspecific(ctx->tlskey, NULL); } pthread_key_delete(ctx->tlskey); |