[tor-bugs] #24633 [Core Tor/Tor]: to->pending->tqh_last is 0xFFFFFFFFFFFFFFFF。
Tor Bug Tracker & Wiki
blackhole at torproject.org
Wed Dec 20 01:36:20 UTC 2017
#24633: to->pending->tqh_last is 0xFFFFFFFFFFFFFFFF。
-------------------------------------------------+-------------------------
Reporter: sx5486510 | Owner: nickm
Type: defect | Status:
| accepted
Priority: Medium | Milestone: Tor:
| 0.3.2.x-final
Component: Core Tor/Tor | Version: Tor:
| 0.3.2.1-alpha
Severity: Normal | Resolution:
Keywords: msvc 029-backport 030-backport | Actual Points:
031-backport |
Parent ID: | Points:
Reviewer: | Sponsor:
-------------------------------------------------+-------------------------
Comment (by sx5486510):
I modify the function like this:
src/ext/timeouts/timeout-bitops.c
...
#define LT(n) n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n
static const char logTable[256] = {
0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
LT(5), LT(6), LT(6), LT(7), LT(7), LT(7), LT(7),
LT(8), LT(8), LT(8), LT(8), LT(8), LT(8), LT(8), LT(8)
};
#undef LT
...
static __inline int clz32(unsigned long val)
{
unsigned int t;
if ((t = val >> 24)) {
return 8 - logTable[t];
}
else if ((t = val >> 16)) {
return 16 - logTable[t];
}
else if ((t = val >> 8)) {
return 24 - logTable[t];
}
else {
return 32 - logTable[val];
}
DWORD zeros = 0;
_BitScanReverse(&zeros, val);
return zeros;
}
...
static __inline int clz64(uint64_t val)
{
unsigned __int64 t;
if ((t = val >> 56)) {
return 8 - logTable[t];
}
else if ((t = val >> 48)) {
return 16 - logTable[t];
}
else if ((t = val >> 40)) {
return 24 - logTable[t];
}
else if ((t = val >> 32)) {
return 32 - logTable[t];
}
else if ((t = val >> 24)) {
return 40 - logTable[t];
}
else if ((t = val >> 16)) {
return 48 - logTable[t];
}
else if ((t = val >> 8)) {
return 56 - logTable[t];
}
else {
return 64 - logTable[val];
}
DWORD zeros = 0;
_BitScanReverse64(&zeros, val);
return zeros;
}
...
The code is copy from here: https://fossies.org/linux/Pike/src/bitvector.h
The test is pass, but i'm not sure the code will return correct result in
any case.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/24633#comment:6>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list