diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 6231b43b..671e22be 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1746,9 +1746,12 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token ) break; case QueueType::CallstackAlloc: ptr = MemRead( &item->callstackAlloc.nativePtr ); - CutCallstack( (void*)ptr, "lua_pcall" ); - SendCallstackPayload( ptr ); - tracy_free( (void*)ptr ); + if( ptr != 0 ) + { + CutCallstack( (void*)ptr, "lua_pcall" ); + SendCallstackPayload( ptr ); + tracy_free( (void*)ptr ); + } ptr = MemRead( &item->callstackAlloc.ptr ); SendCallstackAlloc( ptr ); tracy_free( (void*)ptr ); diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 90ff2a79..2de11060 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -2867,8 +2867,6 @@ void Worker::AddCallstackPayload( uint64_t ptr, const char* _data, size_t _sz ) void Worker::AddCallstackAllocPayload( uint64_t ptr, const char* data, size_t _sz ) { - assert( m_pendingCallstackPtr != 0 ); - CallstackFrameId stack[64]; const auto sz = *(uint32_t*)data; data += 4; assert( sz <= 64 ); @@ -2904,17 +2902,31 @@ void Worker::AddCallstackAllocPayload( uint64_t ptr, const char* data, size_t _s stack[i] = id; } - const auto nativeCs = m_data.callstackPayload[m_pendingCallstackId]; - const auto nsz = nativeCs->size(); - const auto tsz = sz + nsz; + VarArray* arr; + size_t memsize; + if( m_pendingCallstackPtr != 0 ) + { + const auto nativeCs = m_data.callstackPayload[m_pendingCallstackId]; + const auto nsz = nativeCs->size(); + const auto tsz = sz + nsz; - const auto memsize = sizeof( VarArray ) + tsz * sizeof( CallstackFrameId ); - auto mem = (char*)m_slab.AllocRaw( memsize ); - memcpy( mem, stack, sizeof( CallstackFrameId ) * sz ); - memcpy( mem + sizeof( CallstackFrameId ) * sz, nativeCs->data(), sizeof( CallstackFrameId ) * nsz ); + memsize = sizeof( VarArray ) + tsz * sizeof( CallstackFrameId ); + auto mem = (char*)m_slab.AllocRaw( memsize ); + memcpy( mem, stack, sizeof( CallstackFrameId ) * sz ); + memcpy( mem + sizeof( CallstackFrameId ) * sz, nativeCs->data(), sizeof( CallstackFrameId ) * nsz ); - auto arr = (VarArray*)( mem + tsz * sizeof( CallstackFrameId ) ); - new(arr) VarArray( tsz, (CallstackFrameId*)mem ); + arr = (VarArray*)( mem + tsz * sizeof( CallstackFrameId ) ); + new(arr) VarArray( tsz, (CallstackFrameId*)mem ); + } + else + { + memsize = sizeof( VarArray ) + sz * sizeof( CallstackFrameId ); + auto mem = (char*)m_slab.AllocRaw( memsize ); + memcpy( mem, stack, sizeof( CallstackFrameId ) * sz ); + + arr = (VarArray*)( mem + sz * sizeof( CallstackFrameId ) ); + new(arr) VarArray( sz, (CallstackFrameId*)mem ); + } uint32_t idx; auto it = m_data.callstackMap.find( arr );