[tor-bugs] #13192 [Tor]: Collect aggregate stats of total hidden service usage vs total exit usage in Tor network
Tor Bug Tracker & Wiki
blackhole at torproject.org
Fri Mar 27 09:02:13 UTC 2015
#13192: Collect aggregate stats of total hidden service usage vs total exit usage
in Tor network
-----------------------------+---------------------------------------
Reporter: arma | Owner:
Type: enhancement | Status: needs_revision
Priority: normal | Milestone: Tor: 0.2.7.x-final
Component: Tor | Version:
Resolution: | Keywords: SponsorR tor-relay tor-hs
Actual Points: | Parent ID:
Points: |
-----------------------------+---------------------------------------
Comment (by teor):
Once these changes are made, the test fails the clang x86_64 (3.7.0 (trunk
230165) / x86_64-apple-darwin14.1.0) integer undefined behaviour sanitiser
with:
{{{
util/cast_double_to_int64: src/test/test_util.c:4250:3: runtime error:
left shift of negative value -1
}}}
This can be resolved by casting the constant `-1` to `uint64_t` not
`int64_t`:
{{{
tt_i64_op(((uint64_t) -1) << 53, ==,
cast_double_to_int64(-1.0 * pow(2.0, 53.0)));
tt_i64_op((((uint64_t) -1) << 53) + 1, ==,
cast_double_to_int64(-1.0 * pow(2.0, 53.0) + 1.0));
}}}
See http://stackoverflow.com/a/22734721
<blockquote>
The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits
are filled with zeros. If E1 has an unsigned type, the value of the result
is E1×2E2, reduced modulo one more than the maximum value representable in
the result type. If E1 has a signed type and non-negative value, and
E1×2E2 is representable in the result type, then that is the resulting
value; otherwise, the behaviour is undefined.
...
If E1 is a signed type with negative value then the behaviour of left
shifting is undefined. This is an easy route to undefined behaviour which
may easily get overlooked.
</blockquote>
The tests then succeed on OS X 10.10.2 / Xcode 6.3 beta / clang 3.7.0 with
integer undefined behaviour checks / x86_64.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/13192#comment:61>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list