+static void CHECK_ACCESS(void* ptr) {
+ DO_ASSERT(!pthread_mutex_lock(&allocation_mtx));
+ allocation* it = allocation_ll;
+ while (it->ptr != ptr) {
+ it = it->next;
+ if (it == NULL) {
+ DEBUG_PRINT("ERROR: Tried to access unknown pointer %p at:\\n", ptr);
+ void* bt[BT_MAX];
+ int bt_len = backtrace(bt, BT_MAX);
+ backtrace_symbols_fd(bt, bt_len, STDERR_FILENO);
+ DEBUG_PRINT("\\n\\n");
+ DO_ASSERT(!pthread_mutex_unlock(&allocation_mtx));
+ return; // addrsan should catch and print more info than we have
+ }
+ }
+ DO_ASSERT(!pthread_mutex_unlock(&allocation_mtx));
+}
+