[tor-bugs] #31736 [Core Tor/Tor]: Stop using mutex_destroy(), when multiple threads can still access the mutex

Tor Bug Tracker & Wiki blackhole at torproject.org
Tue Sep 24 03:04:22 UTC 2019


#31736: Stop using mutex_destroy(), when multiple threads can still access the
mutex
-------------------------------------------------+-------------------------
 Reporter:  teor                                 |          Owner:  teor
     Type:  defect                               |         Status:
                                                 |  needs_review
 Priority:  Medium                               |      Milestone:  Tor:
                                                 |  0.4.2.x-final
Component:  Core Tor/Tor                         |        Version:  Tor:
                                                 |  0.3.5.1-alpha
 Severity:  Normal                               |     Resolution:
 Keywords:  consider-backport-after-042-stable,  |  Actual Points:  0.4
  consider-backport-if-needed, diagnostics,      |
  042-should, 035-backport-maybe, 040-backport-  |
  maybe, 041-backport-maybe, regression,         |
  BugSmashFund                                   |
Parent ID:  #31614                               |         Points:  0.2
 Reviewer:                                       |        Sponsor:
-------------------------------------------------+-------------------------
Changes (by teor):

 * status:  assigned => needs_review
 * actualpoints:  0.2 => 0.4


Comment:

 Replying to [comment:4 nickm]:
 > Hi!  This all looks plausible to me at first glance. Here's another
 question to check on, however:
 >
 >  * Have you thought about what happens on re-initialization?

 We must destroy the mutexes, or re-initialising them triggers undefined
 behaviour. (On both pthreads and Windows threads.) And there is no way to
 determine if the mutex has already been initialised.

 Therefore, we should continue to use the old code, but:
 * avoid freeing some locked mutexes by acquiring and releasing the lock in
 tor_mutex_uninit(), and
 * add comments explaining the issue, so we can diagnose any crashes or
 deadlocks more easily.

 Here is my PR:
 * 0.3.5: https://github.com/torproject/tor/pull/1346

 I think we should leave restart debugging for #31735, because I am out of
 time on this issue.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/31736#comment:7>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list