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

fix: provide non-static recursive mutex initializer #1113

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
- Add option to set debug log level. ([#1107](https://github.com/getsentry/sentry-native/pull/1107))
- Provide support for C++17 compilers when using the `crashpad` backend. ([#1110](https://github.com/getsentry/sentry-native/pull/1110), [crashpad#116](https://github.com/getsentry/crashpad/pull/116), [mini_chromium#1](https://github.com/getsentry/mini_chromium/pull/1))

**Fixes**:

- Provide a mutex-initializer on platforms that have no static pthread initializer for recursive mutexes. ([#1113](https://github.com/getsentry/sentry-native/pull/1113))

## 0.7.17

**Features**:
Expand Down
25 changes: 20 additions & 5 deletions src/sentry_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,29 @@ typedef pthread_cond_t sentry_cond_t;
PTHREAD_MUTEX_RECURSIVE \
} \
}
# elif defined(__FreeBSD__)
// Don't define `SENTRY__MUTEX_INIT` but instead provide a new definition that
// can be used by platforms requiring dynamic recursive mutex initialization.
# define SENTRY__MUTEX_INIT_DYN
# else
# define SENTRY__MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER
# endif
# define sentry__mutex_init(Mutex) \
do { \
sentry_mutex_t tmp = SENTRY__MUTEX_INIT; \
*(Mutex) = tmp; \
} while (0)
# ifdef SENTRY__MUTEX_INIT_DYN
# define sentry__mutex_init(Mutex) \
do { \
pthread_mutexattr_t attr; \
pthread_mutexattr_init(&attr); \
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \
pthread_mutex_init(Mutex, &attr); \
pthread_mutexattr_destroy(&attr); \
} while (0)
# else
# define sentry__mutex_init(Mutex) \
do { \
sentry_mutex_t tmp = SENTRY__MUTEX_INIT; \
*(Mutex) = tmp; \
} while (0)
# endif
# define sentry__mutex_lock(Mutex) \
do { \
if (sentry__block_for_signal_handler()) { \
Expand Down
Loading