tsan2(44758,0x10a8fb600) malloc: nano zone abandoned due to inability to preallocate reserved vm space.
==================
WARNING: ThreadSanitizer: destroy of a locked mutex (pid=44758)
  #0 __tsan_mutex_destroy <null>:3 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x48c9b)
  #1 main <null>:2 (tsan2:x86_64+0x1000026f0)
 and:
  #0 __tsan_mutex_post_lock <null>:3 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x48dc2)
  #1 main <null>:2 (tsan2:x86_64+0x1000026dd)
 Location is global 'memory' at 0x0001056e80dc (tsan2+0x0001000080dc)
 Mutex M20 (0x0001056e80dc) created at:
  #0 __tsan_mutex_create <null>:3 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x48c1b)
  #1 main <null>:2 (tsan2:x86_64+0x1000026b5)
SUMMARY: ThreadSanitizer: destroy of a locked mutex (tsan2:x86_64+0x1000026f0) in main+0x80
==================
==================
WARNING: ThreadSanitizer: data race (pid=44758)
 Write of size 1 at 0x0001056e80d8 by thread T1:
  #0 f() <null>:2 (tsan2:x86_64+0x100002658)
  #1 void* std::__1::__thread_proxy_cxx03<std::__1::__thread_invoke_pair<void (*)()> >(void*) <null>:2 (tsan2:x86_64+0x100002b9f)
 Previous read of size 1 at 0x0001056e80d8 by main thread (mutexes: write M5629503920308444, write M0):
  #0 main <null>:2 (tsan2:x86_64+0x1000027a3)
 Location is global 'flag' at 0x0001056e80d8 (tsan2+0x0001000080d8)
 Mutex M5629503920308444 is already destroyed.
 Mutex M0 (0x0001056e80dc) created at:
  #0 __tsan_mutex_create <null>:3 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x48c1b)
  #1 main <null>:2 (tsan2:x86_64+0x100002737)
 Thread T1 (tid=1130742, running) created by main thread at:
  #0 pthread_create <null>:3 (libclang_rt.tsan_osx_dynamic.dylib:x86_64h+0x2ca2d)
  #1 std::__1::__libcpp_thread_create(_opaque_pthread_t**, void* (*)(void*), void*) <null>:2 (tsan2:x86_64+0x100002af5)
  #2 std::__1::thread::thread<void (*)()>(void (*)()) <null>:2 (tsan2:x86_64+0x1000028f8)
  #3 std::__1::thread::thread<void (*)()>(void (*)()) <null>:2 (tsan2:x86_64+0x100002835)
  #4 main <null>:2 (tsan2:x86_64+0x10000278d)
SUMMARY: ThreadSanitizer: data race (tsan2:x86_64+0x100002658) in f()+0x18
==================
```