[tor-bugs] #29527 [Core Tor/Tor]: Division by zero: undefined behaviour in circuitpadding/circuitpadding_sample_distribution test

Tor Bug Tracker & Wiki blackhole at torproject.org
Mon Feb 25 02:10:14 UTC 2019


#29527: Division by zero: undefined behaviour in
circuitpadding/circuitpadding_sample_distribution test
-------------------------------------------------+-------------------------
 Reporter:  teor                                 |          Owner:  (none)
     Type:  defect                               |         Status:  new
 Priority:  High                                 |      Milestone:  Tor:
                                                 |  0.4.0.x-final
Component:  Core Tor/Tor                         |        Version:
 Severity:  Normal                               |     Resolution:
 Keywords:  regression, tor-ci, tor-test,        |  Actual Points:
  040-must                                       |
Parent ID:                                       |         Points:
 Reviewer:                                       |        Sponsor:
-------------------------------------------------+-------------------------

Comment (by teor):

 Replying to [comment:7 riastradh]:
 >
 > ...
 >
 > I tried running the tests with tinytest.c modified to do
 `feenableexcept(FE_INVALID)` first thing in tinytest_main (needs `#define
 _GNU_SOURCE` and `#include <fenv.h>`).  This turned up only one invalid
 operation in the tests: the logsumexp in test_stochastic_geometric_impl
 slightly exceeds zero, so log1mexp performs an invalid operation (log of
 negative); it is safe to replace `log1mexp(logsumexp(...))` here by
 `log1mexp(fmin(0, logsumexp(...)))` to avoid this.
 >
 > (The issue in test_stochastic_geometric_impl does not invalidate any of
 the test results: the NaN it produced without exceptions trapped was never
 used again in the subsequent computation, because it should have been an
 effectively zero probability (less than e^-100^ = 2^-144^ or something)
 and the corresponding ''count'' is always zero in tests as it should be,
 so psi_test ignores the probability.  If the count were ever nonzero,
 indicating a broken geometric sampler, psi would be computed as a NaN and
 the psi test would fail.  So floating-point arithmetic once again does the
 right thing in the end, though it still would probably be better to use
 `log1mexp(fmin(0, logsumexp(...)))`.)

 Ok, let's fix these issues in this ticket?
 #29528 deals with the general case.

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


More information about the tor-bugs mailing list