diff --git a/include/iocore/eventsystem/Lock.h b/include/iocore/eventsystem/Lock.h index f41c862ba71..2fcef5fdadd 100644 --- a/include/iocore/eventsystem/Lock.h +++ b/include/iocore/eventsystem/Lock.h @@ -261,7 +261,13 @@ Mutex_trylock( if (m->thread_holding != t) { if (!ink_mutex_try_acquire(&m->the_mutex)) { #ifdef DEBUG - lock_waiting(m->srcloc, m->handler); + // Report the waiting site, not the holder's. m->srcloc and m->handler + // belong to whichever thread holds the mutex, and this thread just failed + // to acquire it, so reading them races with the holder publishing them + // below and clearing them in Mutex_unlock(). Any holder snapshot is stale + // the instant it is taken anyway; lock_holding() still reports the holder + // from Mutex_unlock(), where the fields are owned by the caller. + lock_waiting(location, ahandler); #ifdef LOCK_CONTENTION_PROFILING m->unsuccessful_nonblocking_acquires++; m->nonblocking_acquires++;