Opened 12 years ago

Closed 12 years ago

#4736 closed Bugs (fixed)

MinGW: tss crashes (SIGSEGV) in ~thread_specific_ptr

Reported by: Jim Bell <jim@…> Owned by: Anthony Williams
Milestone: Boost 1.45.0 Component: thread
Version: Boost 1.44.0 Severity: Showstopper
Keywords: mingw tss SIGSEGV thread_specific_ptr destructor set_tss_data Cc: jim@…, Bryce Adelstein Lelbach

Description

tss crashes with a SIGSEGV in the destructor of thread_specific_ptr under mingw, inside boost::detail::set_tss_data().

After main() exits, apparently cleanup_tls_key() gets called some time prior to the thread_specific_ptr clean-up.

Then inside set_tss_data(), get_or_make_current_thread_data() returns 0, and dereferencing it (current_thread_data->tss_data, line 589) causes the crash.

get_or_make_... actually makes one, but get_current_thread_data() won't return it because current_thread_tls_key is reset. So there's a little resource leak here, too. Though I don't think that's important this late in the program's termination sequence, you could check current_thread_tls_key explicitly in get_or_make_... and avoid it.

Attachments (1)

tss-mingw-2010-10-14.patch (791 bytes ) - added by Jim Bell <jim@…> 12 years ago.

Download all attachments as: .zip

Change History (13)

by Jim Bell <jim@…>, 12 years ago

Attachment: tss-mingw-2010-10-14.patch added

comment:1 by Jim Bell <jim@…>, 12 years ago

There seems to be a race condition involved, as I'm now able to pass the test_tss_lib test on my machine (un-patched) that reliably failed it earlier in the week. As you can see, though, the trunk test for gcc-mingw-4.3.3 also failed this same test and with the same symptoms.

comment:2 by Vladimir Prus, 12 years ago

Milestone: To Be DeterminedBoost-1.45.0
Severity: ProblemShowstopper

comment:3 by anonymous, 12 years ago

Resolution: worksforme
Status: newclosed

Jim, I'm having trouble reproducing this, and I can't find any references to this in the build bot logs. Can you provide self-contained code that produces this error for you? (understandably if there is a race condition, this could be hard to reproduce, but if you provide me with a test case that should reproduce this, I'll run it on my Windows machine and add it to the test matrix).

comment:4 by Bryce Adelstein Lelbach, 12 years ago

Cc: Bryce Adelstein Lelbach added

comment:5 by Jim Bell <jim@…>, 12 years ago

RE: worksforme

Note this log (live as of 2010/10/21 3PM CST):

Run [2010-10-21 16:24:48 UTC]: fail

Running 6 test cases...
tss_instances = 0; tss_total = 5
tss_instances = 0; tss_total = 5

*** No errors detected

Notice both "No errors detected" and "Run [...]: fail" above it. It exited main() just fine, then crashed.

comment:6 by Jim Bell <jim@…>, 12 years ago

Resolution: worksforme
Status: closedreopened

comment:7 by Jim Bell <jim@…>, 12 years ago

Resolution: fixed
Status: reopenedclosed

Even though MinGW-32 still fails the test_tss_lib test, it's now for a different reason, the program terminates cleanly. Fixed.

comment:8 by Katie Chan, 12 years ago

Resolution: fixed
Status: closedreopened

r66482 broke the regex_regress_threaded test case in Regex across the board with MSVC that was previously passing.

comment:9 by Richard Webb <richard.webb@…>, 12 years ago

f.y.i, Several of the Wave regression tests are failing on the release branch with a similar looking error.

comment:10 by Jim Bell <jim@…>, 12 years ago

If this_thread::get_id() gets called before a boost::thread is created, no call to set_current_thread_data() would have been made, and you'd see this symptom.

FWIW, also noticed that the "throw thread_resource_error()" in get_or_make_current_thread_data() is inconsistent with other uses: "boost::throw_exception(thread_resource_error());"

comment:11 by Jim Bell <jim@…>, 12 years ago

r66518 fixes this ticket as originally reported. Please reopen if other libraries are still failing.

comment:12 by Jim Bell <jim@…>, 12 years ago

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