Having Thread::create store a pointer to a string that is passed to
ceph_pthread_setname in Thread::entry_wrapper can lead to using a
pointer in the calling thread's stack that gets freed before use.
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
Thread::Thread()
: thread_id(0),
pid(0),
- cpuid(-1),
- thread_name(NULL)
+ cpuid(-1)
{
}
if (pid && cpuid >= 0)
_set_affinity(cpuid);
- ceph_pthread_setname(pthread_self(), thread_name);
+ ceph_pthread_setname(pthread_self(), thread_name.c_str());
#ifdef WITH_SEASTAR
crimson::os::AlienStore::configure_thread_memory();
#endif
pthread_t thread_id;
pid_t pid;
int cpuid;
- const char *thread_name;
+ std::string thread_name;
void *entry_wrapper();