Monotime resolution and conversion issues on Mac Silicon (M1/M2, iOS)
After getting Tor to build on Mac Silicon (See #40683 (closed) for build hack), I noticed 6 unit test failures. All of the failures have to do with the monotime conversion functions.
The root cause seems to be something to do with the milliseconds per tick concept from the Mac-specific implementation of monotime_init_internal()
. On x86 Mac, the ms_per_tick computed by monotime_init_internal()
is 1000000, yielding a monotime_shift of 19. But on Mac Silicon, the ms_per_tick is 41000000, yielding a monotime_shift of 25. This seems to be causing a bunch of monotime conversion functions to return 0 or other strange values in conversions.
Apple may have reduced the granularity of their clocks due to the PACMAN exploits on Mac Silicon.. is that what we're looking at here? Or is it just some other weirdness?
This is also showing up in Arti: arti#574