Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback not used when clock_gettime is unavailable (crash on OSX < 10.12) #1576

Closed
EvanBalster opened this issue Apr 12, 2022 · 3 comments
Closed

Comments

@EvanBalster
Copy link
Contributor

Describe the bug
The POSIX implementation of NNG uses clock_gettime which is not available on old versions of Mac OS X. The Mac OS X Deployment Target has no bearing on this behavior.

Expected behavior
Mac OS X Deployment Targets less than 10.12 should enable the NNG_USE_GETTIMEOFDAY macro which enables a less performant fallback implementation.

Actual Behavior
NNG's CMake files make no reference to NNG_USE_GETTIMEOFDAY. POSIX builds will always use clock_gettime regardless of its availability.

To Reproduce
Configure and build NNG with a Mac OS X deployment target of 10.11 or lower. Alternatively, configure NNG to build on a POSIX platform lacking clock_gettime.

Run a test application in a debugger, with a breakpoint on nni_clock. Take note of the code that is executed there.

** Environment Details **

  • NNG 1.5.2
  • Mac OS X 10.14 (development machine)
  • Mac OS X 10.7 (deployment target)
  • Apple Clang 11.0.0 (XCode 11.3.1)
  • Static library built via makefile
@EvanBalster EvanBalster changed the title NNG crashes on Mac OS X < 10.12 (calling clock_gettime) Fallback not used when clock_gettime is unavailable (crash on OSX < 10.12) Apr 12, 2022
@gdamore
Copy link
Contributor

gdamore commented Apr 16, 2022

So the workaround is to set NNG_USE_GETTIMEOFDAY. I need to see if I can convince CMake of this. I expect what is happening is that we are detecting a clock_gettime() symbol on macOS versions that are old, but that the implementation is defective. (I.e. compile time checks find it, but at run time it doesn't work. :(

@gdamore
Copy link
Contributor

gdamore commented Apr 16, 2022

well maybe... I do see that we aren't using the check for NNG_HAVE_CLOCKGETTIME.

@gdamore
Copy link
Contributor

gdamore commented Sep 7, 2024

Btw, we are likely to retire support for such old versions of macOS.

Pretty much everyone dropping support for macOS versions more than 5 years old. Go dropped support for 10.15 almost a year ago. (Meaning you need macOS 11 -- Big Sur -- or better.)

On the one hand, I'm unlikely to go far out of my way to intentionally break compatibility with an older OS, but I am also unlikely to go far out of my way supporting an old OS. Right now Apple is only providing support for macOS 12 and newer.

A similar situation exists with Windows and to a lesser extent some Linux distributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants