Skip to content

Crash in Profiler::HandleServerQuery() when creating ScopedZone with pre-allocated SourceLocationData #1260

@tigerssj

Description

@tigerssj

Hello, guys!
I am using tracy to profile my c++ application, I write a function, here is the code:
`GTVoid IGTClient::beginProfileSampler( const GTChar* profileName_, const TRgba& displayColor_, const GTChar* source_, GTUint lineNumber_, const GTChar* szFunc_ ) noexcept {
#ifdef TRACY_ENABLE
#if HS_ENABLE_TRACY_ENABLE
TThreadProfileContext* profileContext_ = G_ClientMgr->getThreadProfileContext( );
hsAssert( profileContext_ != nullptr );

#if 1
	auto *pSourceLocationData_ = ( const tracy::SourceLocationData * )tracy::Profiler::AllocSourceLocation ( lineNumber_,
																											 source_ != nullptr ? source_ : "", source_ != nullptr ? gtstrlen ( source_ ) : 0,
																											 szFunc_ != nullptr ? szFunc_ : "", szFunc_ != nullptr ? gtstrlen ( szFunc_ ) : 0,
																											 profileName_ != nullptr ? profileName_ : "", profileName_ != nullptr ? gtstrlen ( profileName_ ) : 0,
																											 displayColor_.toDowrd ( ) );

 	auto* scopeZone_ = new tracy::ScopedZone ( pSourceLocationData_, -1, true );
#else
	auto *scopeZone_ = new tracy::ScopedZone ( lineNumber_,
										source_, source_ != nullptr ? gtstrlen ( source_ ) : 0,
										szFunc_, szFunc_ != nullptr ? gtstrlen ( szFunc_ ) : 0,
										profileName_, profileName_ != nullptr ? gtstrlen ( profileName_ ) : 0,
										displayColor_.toDowrd ( ) );
#endif


	profileContext_->threadZoneStack_.push ( scopeZone_ );

	return;

however, if I use SourceLocationData to construct a ScopedZone, the application will crash, follow is the crash stack(The crash occurs specifically when the Tracy Profiler GUI connects to my application.):

Image

and code:

Image Image

if I use constructor( tracy_force_inline ScopedZone( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, uint32_t color, int32_t depth = -1, bool is_active = true ) ), everything is ok in Tracy Profiler 0.13.1, the Tracy Version used in my c++ code is 0.13.1 too.

Image.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions