Skip to content

Potential data race in Thread::start() and Thread::_runChild()  #315

@ITWOI

Description

@ITWOI

Hi all,

Our bug scanner has reported a data race issue at thread.cpp#L131 and thread.cpp#L202.

Followings are code snippets.

void Thread::_runChild()
{
    setName(boost::lexical_cast<std::string>(_impl->index));
    _impl->id._impl->pthread = pthread_self();

and

bool Thread::start()
{
    ...
    // avoid memleak, we don't use pthread_join
    pthread_detach(_impl->id._impl->pthread);

The race occurs when _impl->id._impl->pthread = pthread_self(); and pthread_detach(_impl->id._impl->pthread); are executed simultaneously.

SourceBrella Inc.,
Yu

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions