Skip to content

Commit

Permalink
[FSA] Fix use-after-free in cleanup
Browse files Browse the repository at this point in the history
If we cleanup the main thread (with it's per-thread FSA free list) after
cleaning up the FSA itself, that corresponds to a use-after-free, and we
should not.
  • Loading branch information
bdw committed Aug 7, 2018
1 parent 265c916 commit a742be3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/moar.c
Expand Up @@ -588,8 +588,6 @@ void MVM_vm_destroy_instance(MVMInstance *instance) {
uv_mutex_destroy(&instance->nfg->update_mutex);
MVM_nfg_destroy(instance->main_thread);

/* Clean up fixed size allocator */
MVM_fixed_size_destroy(instance->fsa);

/* Clean up integer constant and string cache. */
uv_mutex_destroy(&instance->mutex_int_const_cache);
Expand All @@ -603,6 +601,9 @@ void MVM_vm_destroy_instance(MVMInstance *instance) {
MVM_tc_destroy(instance->main_thread);
uv_mutex_destroy(&instance->mutex_threads);

/* Clean up fixed size allocator */
MVM_fixed_size_destroy(instance->fsa);

/* Clear up VM instance memory. */
MVM_free(instance);
}
Expand Down

0 comments on commit a742be3

Please sign in to comment.