Fix memory events not being attributed to fibers.

Alloc and free events stored the OS thread, so the memory view's
Zone alloc/Zone free columns resolved the zone on the OS thread's
timeline instead of the currently-running fiber. Attribute them to
the active fiber the same way zone and message events are
(follow ThreadData::fiber).
This commit is contained in:
Bartosz Taudul
2026-08-15 15:14:33 +02:00
parent b10d466a38
commit 54ecee1f74

View File

@@ -6302,14 +6302,19 @@ MemEvent* Worker::ProcessMemAllocImpl( MemData& memdata, const QueueMemAlloc& ev
if( m_data.lastTime < time ) m_data.lastTime = time;
NoticeThread( ev.thread );
const auto thread = CompressThread( ev.thread );
uint64_t tid = ev.thread;
auto td = RetrieveThread( tid, m_data.threadDataLast );
assert( td );
if( td->fiber ) tid = td->fiber->id;
const auto thread = CompressThread( tid );
auto it = memdata.active.find( ev.ptr );
if( it != memdata.active.end() )
{
if( !m_ignoreMemAllocFaults )
{
MemAllocTwiceFailure( ev.thread );
MemAllocTwiceFailure( tid );
return nullptr;
}
@@ -6369,7 +6374,12 @@ MemEvent* Worker::ProcessMemFreeImpl( MemData& memdata, const QueueMemFree& ev )
if( m_data.lastTime < time ) m_data.lastTime = time;
NoticeThread( ev.thread );
auto mem = MemDataFree( memdata, it, time, CompressThread( ev.thread ) );
uint64_t tid = ev.thread;
auto td = RetrieveThread( tid, m_data.threadDataLast );
assert( td );
if( td->fiber ) tid = td->fiber->id;
auto mem = MemDataFree( memdata, it, time, CompressThread( tid ) );
MemAllocChanged( memdata, time );
return mem;
}