[tor-bugs] #14090 [Tor]: Test case "laplace" fails on Raspberry Debian 7.6

Tor Bug Tracker & Wiki blackhole at torproject.org
Wed Jan 14 14:15:27 UTC 2015


#14090: Test case "laplace" fails on Raspberry Debian 7.6
------------------------+--------------------------------
     Reporter:  TvdW    |      Owner:
         Type:  defect  |     Status:  new
     Priority:  normal  |  Milestone:
    Component:  Tor     |    Version:  Tor: 0.2.6.2-alpha
   Resolution:          |   Keywords:
Actual Points:          |  Parent ID:
       Points:          |
------------------------+--------------------------------

Comment (by asn):

 After a discussion with Yawning and nickm, it seems that the cause of this
 is the following part of the C spec:
 {{{
 When a finite value of real floating type is converted to an integer
 type other than _Bool, the fractional part is discarded (i.e., the
 value is truncated toward zero). If the value of the integral part
 cannot be represented by the integer type, the behavior is undefined
 }}}

 So basically, if `sample_laplace_distribution()` returns a `double` whose
 integral part is bigger than what `int64_t` can represent, then that value
 gets casted to `int64_t` and causes undefined behavior.

 Nick suggested checking for big values like this in
 `sample_laplace_distribution()` in a fashion similar to this:
 {{{
 double result = mu - b * (p > 0.5 ? 1.0 : -1.0)
                        * tor_mathlog(1.0 - 2.0 * fabs(p - 0.5));
 if (result >= INT64_MAX)
    return INT64_MAX;
 else if (result <= INT64_MIN)
    return INT64_MIN;
 else
    return (int64_t) result;
 }}}

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


More information about the tor-bugs mailing list