Fixes two bugs causing crashes with -use_physical:
-
Records the drcontext used for hashtable creation to ensure the same one is used at destruction as a different thread can call the exit event.
-
Orders the drmemtrace thread exit event before the drmodtrack one to ensure drmodtrack access during the final thread buffer output is safe.
These fixes were manually tested on large multi-threaded applications where these two crashes showed up before and disappear with the fixes.
Issue: #4014