This is an automated email from the git hooks/post-receive script.
dgoulet pushed a change to branch main in repository tor.
from 5080a4ff67 Merge branch 'maint-0.4.7' new e531d4d1b9 Fix a completely wrong calculation in mach monotime_init_internal() new e86833ade6 Merge branch 'maint-0.4.5' into maint-0.4.7 new 28413e7560 Merge branch 'maint-0.4.7'
The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
Summary of changes: changes/bug40684 | 6 ++++++ src/lib/time/compat_time.c | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 changes/bug40684
This is an automated email from the git hooks/post-receive script.
dgoulet pushed a commit to branch main in repository tor.
commit e531d4d1b9753e80b56a28805b01c014a1fe5d51 Author: Nick Mathewson nickm@torproject.org AuthorDate: Thu Oct 13 13:40:10 2022 -0400
Fix a completely wrong calculation in mach monotime_init_internal()
Bug 1: We were purporting to calculate milliseconds per tick, when we *should* have been computing ticks per millisecond.
Bug 2: Instead of computing either one of those, we were _actually_ computing femtoseconds per tick.
These two bugs covered for one another on x86 hardware, where 1 tick == 1 nanosecond. But on M1 OSX, 1 tick is about 41 nanoseconds, causing surprising results.
Fixes bug 40684; bugfix on 0.3.3.1-alpha. --- changes/bug40684 | 6 ++++++ src/lib/time/compat_time.c | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/changes/bug40684 b/changes/bug40684 new file mode 100644 index 0000000000..8c751ede2c --- /dev/null +++ b/changes/bug40684 @@ -0,0 +1,6 @@ + o Major bugfixes (OSX): + - Fix coarse-time computation on Apple platforms (like Mac M1) where + the Mach absolute time ticks do not correspond directly to + nanoseconds. Previously, we computed our shift value wrong, which + led us to give incorrect timing results. + Fixes bug 40684; bugfix on 0.3.3.1-alpha. diff --git a/src/lib/time/compat_time.c b/src/lib/time/compat_time.c index 6bbad4f98a..9a5ce062d7 100644 --- a/src/lib/time/compat_time.c +++ b/src/lib/time/compat_time.c @@ -253,11 +253,14 @@ monotime_init_internal(void) tor_assert(mach_time_info.denom != 0);
{ - // approximate only. - uint64_t ns_per_tick = mach_time_info.numer / mach_time_info.denom; - uint64_t ms_per_tick = ns_per_tick * ONE_MILLION; + // We want to compute this, approximately: + // uint64_t ns_per_tick = mach_time_info.numer / mach_time_info.denom; + // uint64_t ticks_per_ms = ONE_MILLION / ns_per_tick; + // This calculation multiplies first, though, to improve accuracy. + uint64_t ticks_per_ms = (ONE_MILLION * mach_time_info.denom) + / mach_time_info.numer; // requires that tor_log2(0) == 0. - monotime_shift = tor_log2(ms_per_tick); + monotime_shift = tor_log2(ticks_per_ms); } { // For converting ticks to milliseconds in a 32-bit-friendly way, we
This is an automated email from the git hooks/post-receive script.
dgoulet pushed a commit to branch main in repository tor.
commit e86833ade650104d610327432f2e646d13f6a2a2 Merge: c8d8fa0d36 e531d4d1b9 Author: David Goulet dgoulet@torproject.org AuthorDate: Fri Oct 14 09:12:23 2022 -0400
Merge branch 'maint-0.4.5' into maint-0.4.7
changes/bug40684 | 6 ++++++ src/lib/time/compat_time.c | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-)
This is an automated email from the git hooks/post-receive script.
dgoulet pushed a commit to branch main in repository tor.
commit 28413e75605cc2d05a2a3e4c766bfbe0a47d848d Merge: 5080a4ff67 e86833ade6 Author: David Goulet dgoulet@torproject.org AuthorDate: Fri Oct 14 09:12:23 2022 -0400
Merge branch 'maint-0.4.7'
changes/bug40684 | 6 ++++++ src/lib/time/compat_time.c | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-)
tor-commits@lists.torproject.org