Opened 9 years ago

Closed 9 years ago

#8530 closed Bugs (fixed)

[Coverity] Unused variable thread_handle, uninitialized variable cond_mutex in thread/pthread/thread_data.hpp

Reported by: Dan Kegel <dank@…> Owned by: viboes
Milestone: Boost 1.54.0 Component: thread
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description (last modified by viboes)

This was found in an older release, but is still present in trunk.

Coverity complains

134                 thread_data_base():
135                     done(false),join_started(false),joined(false),
136                     thread_exit_callbacks(0),
137                     current_cond(0),
138                     notify(),
139                     async_states_()
140     //#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
141                     , interrupt_enabled(true)
142                     , interrupt_requested(false)
143     //#endif

(2) Event uninit_member: Non-static class member "thread_handle" is not initialized in this constructor nor in any functions

that it calls.

(4) Event uninit_member: Non-static class member "cond_mutex" is not initialized in this constructor nor in any functions

that it calls.

Initializing the two fields to zero seems reasonable, and makes coverity happy.

To repeat (assuming you have a coverity license, and bjam in $HOME/local/bin):

PATH=/opt/coverity/cov-analysis-linux64-6.5.1/bin:$HOME/local/bin:$PATH cov-configure --gcc rm -rf covlog mkdir -p covlog cov-build --dir covlog bjam t_threads cov-analyze --dir covlog cov-format-errors --dir covlog find covlog -type f | xargs grep cond_mutex.*not.*init find covlog -type f | xargs grep thread_handle.*not.*init

If grep finds anything, you've got the problem.

The attached patch makes the greps not find anything.

Attachments (1)

boost-pthread-data.patch (597 bytes ) - added by Dan Kegel <dank@…> 9 years ago.
Draft patch to initialize the affected member variables

Download all attachments as: .zip

Change History (6)

by Dan Kegel <dank@…>, 9 years ago

Attachment: boost-pthread-data.patch added

Draft patch to initialize the affected member variables

comment:1 by Dan Kegel <dank@…>, 9 years ago

Sorry about the formatting. There are a lot of line breaks missing.

comment:2 by viboes, 9 years ago

Description: modified (diff)

comment:3 by viboes, 9 years ago

Owner: changed from Anthony Williams to viboes
Status: newassigned

comment:4 by viboes, 9 years ago

Milestone: To Be DeterminedBoost 1.54.0

Committed revision [84096].

comment:5 by viboes, 9 years ago

Resolution: fixed
Status: assignedclosed

Merged from trunk [84101].

Note: See TracTickets for help on using tickets.