mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
util: Change TraceThread's "name" type: "const char*" -> "const std::string" (#3609)
Having "const char*" leads to undefined behaviour if the "const char*" is deallocated before the thread used it. Co-Authored-By: UdjinM6 <UdjinM6@users.noreply.github.com> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
This commit is contained in:
parent
fc6fe505ca
commit
f44dd06eef
@ -434,9 +434,9 @@ void RenameThreadPool(ctpl::thread_pool& tp, const char* baseName);
|
|||||||
/**
|
/**
|
||||||
* .. and a wrapper that just calls func once
|
* .. and a wrapper that just calls func once
|
||||||
*/
|
*/
|
||||||
template <typename Callable> void TraceThread(const char* name, Callable func)
|
template <typename Callable> void TraceThread(const std::string name, Callable func)
|
||||||
{
|
{
|
||||||
std::string s = strprintf("dash-%s", name);
|
std::string s = "dash-" + name;
|
||||||
RenameThread(s.c_str());
|
RenameThread(s.c_str());
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -450,7 +450,7 @@ template <typename Callable> void TraceThread(const char* name, Callable func)
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
PrintExceptionContinue(std::current_exception(), name);
|
PrintExceptionContinue(std::current_exception(), name.c_str());
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user