Opened 7 years ago

Closed 7 years ago

#11796 closed Bugs (fixed)

Thread move assignment operator, does not detach previous thread data

Reported by: saboorian@… Owned by: viboes
Milestone: Boost 1.60.0 Component: thread
Version: Boost 1.59.0 Severity: Problem
Keywords: Cc:

Description

In thread V2, thread dtor releases thread data, but move assignment operator won't release current threads data before pointing to others data.
I've attached a sample program which reproduces this problem.
(Tested on Ubuntu 15.10 with gcc 5.2.1)

Attachments (1)

thread.cpp (340 bytes ) - added by saboorian@… 7 years ago.

Download all attachments as: .zip

Change History (8)

by saboorian@…, 7 years ago

Attachment: thread.cpp added

comment:1 by viboes, 7 years ago

Owner: changed from Anthony Williams to viboes
Status: newassigned

comment:2 by viboes, 7 years ago

By V2, do you mean that if you add -DBOOST_THREAD_VERSION=3, the issue is not present?

comment:3 by viboes, 7 years ago

Which std version c++98 or c++11?

comment:4 by saboorian@…, 7 years ago

I've tested with c++11.
It only happens with thread V2, because with V3 not joining/detaching a joinable thread leads to std::terminate.
Actually the attached file does not show any error, and that's because I added a thread detach before assigning to a new instance. so If you want to see the error you should remove line 8, and you'll get thread resource error.

comment:5 by viboes, 7 years ago

Milestone: To Be DeterminedBoost 1.60.0

You are right. Please let me know if the following works for you.

https://github.com/boostorg/thread/commit/9f55587ab0236ac1ea4203a3c0c44bc9f252f236

in reply to:  5 comment:6 by saboorian@…, 7 years ago

Yes. This change solves the problem.
Thanks for this great library.

comment:7 by viboes, 7 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.