Skip to content

Commit f5c5568

Browse files
authored
Merge pull request #250 from pythonspeed/248-macos-monterey
macOS monterey fixes
2 parents 504cd5b + 54dc48e commit f5c5568

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.changelog/248.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed crashes on macOS Monterey.

filpreload/src/_filpreload.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ static void __attribute__((constructor)) constructor() {
168168
exit(1);
169169
}
170170

171+
#ifdef __APPLE__
172+
// On macOS Monterey dlsym() is pointing at symbols in current shared library
173+
// for some reason, so just use DYLD_INTERPOSE.
174+
underlying_real_mmap = REAL_IMPL(mmap);
175+
underlying_real_pthread_create = REAL_IMPL(pthread_create);
176+
underlying_real_fork = REAL_IMPL(fork);
177+
#else
171178
underlying_real_mmap = dlsym(RTLD_NEXT, "mmap");
172179
if (!underlying_real_mmap) {
173180
fprintf(stderr, "Couldn't load mmap(): %s\n", dlerror());
@@ -183,7 +190,7 @@ static void __attribute__((constructor)) constructor() {
183190
fprintf(stderr, "Couldn't load fork(): %s\n", dlerror());
184191
exit(1);
185192
}
186-
193+
#endif
187194
// Initialize Rust static state before we start doing any calls via malloc(),
188195
// to ensure we don't get unpleasant reentrancy issues.
189196
pymemprofile_reset("/tmp");

0 commit comments

Comments
 (0)