From 42c49b6ba997520c75b5e8b58c12609ca6df8aab Mon Sep 17 00:00:00 2001 From: Jeff Daily Date: Thu, 5 Sep 2019 03:04:19 -0700 Subject: [PATCH] fix bug where HIP_DB=1 seg faults at startup (#1388) [ROCm/clr commit: 3d7c146296a6b6d8d588c5836785d5a11143cc8f] --- projects/clr/hipamd/src/hip_hcc.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/projects/clr/hipamd/src/hip_hcc.cpp b/projects/clr/hipamd/src/hip_hcc.cpp index 96b8e84298..899959a7ee 100644 --- a/projects/clr/hipamd/src/hip_hcc.cpp +++ b/projects/clr/hipamd/src/hip_hcc.cpp @@ -220,8 +220,17 @@ TidInfo::TidInfo() : _apiSeqNum(0) { tid_ss_num << std::this_thread::get_id(); tid_ss << std::hex << std::stoull(tid_ss_num.str()); - tprintf(DB_API, "HIP initialized short_tid#%d (maps to full_tid: 0x%s)\n", _shortTid, - tid_ss.str().c_str()); + // cannot use tprintf here since it will recurse back into TlsData constructor +#if COMPILE_HIP_DB + if (HIP_DB & (1 << DB_API)) { + char msgStr[1000]; + snprintf(msgStr, sizeof(msgStr), + "HIP initialized short_tid#%d (maps to full_tid: 0x%s)\n", + tid(), tid_ss.str().c_str()); + fprintf(stderr, " %ship-%s pid:%d tid:%d:%s%s", dbName[DB_API]._color, + dbName[DB_API]._shortName, pid(), tid(), msgStr, KNRM); + } +#endif }; }