mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 04:23:51 +00:00
Don't mark FastVector element as used until it's ready.
This should prevent a race condition that would result in invalid last element of the queue, in case a freezed thread already got the queue item, but didn't wrote to it (or didn't wrote fully).
This commit is contained in:
parent
8c0ff67796
commit
facb05f8cb
@ -60,6 +60,17 @@ public:
|
||||
return m_write++;
|
||||
}
|
||||
|
||||
T* prepare_next()
|
||||
{
|
||||
if( m_write == m_end ) AllocMore();
|
||||
return m_write;
|
||||
}
|
||||
|
||||
void commit_next()
|
||||
{
|
||||
m_write++;
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
m_write = m_ptr;
|
||||
|
@ -381,9 +381,10 @@ private:
|
||||
static tracy_force_inline void SendCallstackMemory( void* ptr )
|
||||
{
|
||||
#ifdef TRACY_HAS_CALLSTACK
|
||||
auto item = s_profiler.m_serialQueue.push_next();
|
||||
auto item = s_profiler.m_serialQueue.prepare_next();
|
||||
MemWrite( &item->hdr.type, QueueType::CallstackMemory );
|
||||
MemWrite( &item->callstackMemory.ptr, (uint64_t)ptr );
|
||||
s_profiler.m_serialQueue.commit_next();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -391,7 +392,7 @@ private:
|
||||
{
|
||||
assert( type == QueueType::MemAlloc || type == QueueType::MemAllocCallstack );
|
||||
|
||||
auto item = s_profiler.m_serialQueue.push_next();
|
||||
auto item = s_profiler.m_serialQueue.prepare_next();
|
||||
MemWrite( &item->hdr.type, type );
|
||||
MemWrite( &item->memAlloc.time, GetTime() );
|
||||
MemWrite( &item->memAlloc.thread, thread );
|
||||
@ -406,17 +407,19 @@ private:
|
||||
assert( sizeof( size ) == 8 );
|
||||
memcpy( &item->memAlloc.size, &size, 6 );
|
||||
}
|
||||
s_profiler.m_serialQueue.commit_next();
|
||||
}
|
||||
|
||||
static tracy_force_inline void SendMemFree( QueueType type, const uint64_t thread, const void* ptr )
|
||||
{
|
||||
assert( type == QueueType::MemFree || type == QueueType::MemFreeCallstack );
|
||||
|
||||
auto item = s_profiler.m_serialQueue.push_next();
|
||||
auto item = s_profiler.m_serialQueue.prepare_next();
|
||||
MemWrite( &item->hdr.type, type );
|
||||
MemWrite( &item->memFree.time, GetTime() );
|
||||
MemWrite( &item->memFree.thread, thread );
|
||||
MemWrite( &item->memFree.ptr, (uint64_t)ptr );
|
||||
s_profiler.m_serialQueue.commit_next();
|
||||
}
|
||||
|
||||
double m_timerMul;
|
||||
|
Loading…
x
Reference in New Issue
Block a user