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

Crash on macOS 10.11 in isPlatformOrVariantPlatformVersionAtLeast #497

Closed
1 of 3 tasks
MaxLeb opened this issue Mar 16, 2021 · 3 comments · Fixed by #524
Closed
1 of 3 tasks

Crash on macOS 10.11 in isPlatformOrVariantPlatformVersionAtLeast #497

MaxLeb opened this issue Mar 16, 2021 · 3 comments · Fixed by #524

Comments

@MaxLeb
Copy link

MaxLeb commented Mar 16, 2021

Description

Since we updated to Sentry SDK 0.4.6, we are seing lots of crashes under macOS 10.11 in the function isPlatformOrVariantPlatformVersionAtLeast

When does the problem happen

  • During build
  • During run-time
  • When capturing a hard crash

Environment

  • OS: macOS 10.11
  • Compiler: Xcode 11.6
  • CMake version and config: -DCMAKE_OSX_DEPLOYMENT_TARGET=10.10 -DCMAKE_OSX_ARCHITECTURES=x86_64

Steps To Reproduce

On macOS 10.11, it seems to happen when calling cleanup

Log output

libsentry +0x43fff __isPlatformOrVariantPlatformVersionAtLeast.cold.1
libsentry +0x1506d sentry_envelope_serialize_ratelimited(src/sentry_sdk-0.4.6/src/sentry_envelope.c:341)
libsentry +0x1a053 sentry__prepare_http_request(src/sentry_sdk-0.4.6/src/sentry_transport.c:142)
libsentry +0x1e730 sentry__curl_send_task(src/sentry_sdk-0.4.6/src/transports/sentry_transport_curl.c:137)
libsentry +0x1959c worker_thread(src/sentry_sdk-0.4.6/src/sentry_sync.c:257)
libsentry +0x043fff __isPlatformOrVariantPlatformVersionAtLeast.cold.1
libsentry +0x013533 sentry_shutdown(src/sentry_sdk-0.4.6/src/sentry_core.c:200)
@MaxLeb
Copy link
Author

MaxLeb commented Mar 16, 2021

I managed to run it on a macOS 10.11 and this is the issue:

Symbol not found: _clock_gettime

clock_gettime was added in macOS 10.12 so when building -DCMAKE_OSX_DEPLOYMENT_TARGET=10.10 it does pickup the symbol in the latest SDK but it cannot run on macOS < 10.12

@MaxLeb
Copy link
Author

MaxLeb commented Mar 16, 2021

Here is a patch that works on all macOS versions.
Don't know if it is the best way to handle it but it provides us support for macOS < 10.12

diff --git a/src/sentry_utils.h b/src/sentry_utils.h
index 29c4d32..b1dd78f 100644
--- a/src/sentry_utils.h
+++ b/src/sentry_utils.h
@@ -6,8 +6,13 @@
 #ifdef SENTRY_PLATFORM_WINDOWS
 #    include <winnt.h>
 #else
-#    include <sys/time.h>
-#    include <time.h>
+    #include <sys/time.h>
+    #include <time.h>
+#endif
+
+#ifdef SENTRY_PLATFORM_DARWIN
+    #include <mach/clock.h>
+    #include <mach/mach.h>
 #endif

 /**
@@ -145,6 +150,13 @@ sentry__monotonic_time(void)
     LARGE_INTEGER qpc_counter;
     QueryPerformanceCounter(&qpc_counter);
     return qpc_counter.QuadPart * 1000 / qpc_frequency.QuadPart;
+#elif defined(SENTRY_PLATFORM_DARWIN)
+    clock_serv_t cclock;
+    mach_timespec_t mts;
+    host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
+    clock_get_time(cclock, &mts);
+    mach_port_deallocate(mach_task_self(), cclock);
+    return (uint64_t)mts.tv_sec * 1000 + mts.tv_nsec / 1000000;
 #else
     struct timespec tv;
     return (clock_gettime(CLOCK_MONOTONIC, &tv) == 0)
--

@talaviram
Copy link

We were also able to see this on our end.

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

Successfully merging a pull request may close this issue.

2 participants