[tor-bugs] #25493 [Core Tor/Tor]: Improve patterns for cleaning up static variables on exit/restart

Tor Bug Tracker & Wiki blackhole at torproject.org
Wed Mar 14 11:06:33 UTC 2018


#25493: Improve patterns for cleaning up static variables on exit/restart
------------------------------+--------------------------------
     Reporter:  nickm         |      Owner:  (none)
         Type:  enhancement   |     Status:  new
     Priority:  Medium        |  Milestone:  Tor: 0.3.4.x-final
    Component:  Core Tor/Tor  |    Version:
     Severity:  Normal        |   Keywords:
Actual Points:                |  Parent ID:
       Points:                |   Reviewer:
      Sponsor:  Sponsor8      |
------------------------------+--------------------------------
 In his review for #23524, asn says:
 >I feel like resetting all the global statics on `tor_free_all()` makes
 sense but it's all a very brittle logic. The moment someone adds a new
 global static in that file and doesn't know about this convention of
 wiping at `tor_free_all()`, it will introduce a bug IIUC. Furthermore, the
 fact that some of those vars get reset to 0 and others to 1 is kinda
 arbitrary (and you need to look at their definitions to see if it's
 correct).
 >
 >I wonder what we could do about `3809036` to make it better. Perhaps we
 should de-global those variables, put them in a struct, and initialize
 them in a function, then call that function from some entry-point and
 `tor_free_all()`? That seems like a better approach but probably not so
 trivial. Maybe subject for a future ticket on this area?

 We should indeed look for better patterns to solve this issue, since the
 current approach is indeed fragile.

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


More information about the tor-bugs mailing list