Skip to content

Commit b8d7024

Browse files
committed
Fix Base.StackTraces.lookup(C_NULL - 1) on macOS 12
See comment in diff for explanation. This fixes test/stacktraces.jl on aarch64 macOS 12, and according to an OpenJDK issue where they ran into the same problem, https://git.openjdk.java.net/jdk/pull/6193, probably also x86_64 macOS 12.
1 parent 8dfaf95 commit b8d7024

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/debuginfo.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,14 @@ bool jl_dylib_DI_for_fptr(size_t pointer, object::SectionRef *Section, int64_t *
10781078
struct link_map *extra_info;
10791079
dladdr_success = dladdr1((void*)pointer, &dlinfo, (void**)&extra_info, RTLD_DL_LINKMAP) != 0;
10801080
#else
1081+
#ifdef _OS_DARWIN_
1082+
// On macOS 12, dladdr(-1, …) succeeds and returns the main executable image,
1083+
// despite there never actually being an image there. This is not what we want,
1084+
// as we use -1 as a known-invalid value e.g. in the test suite.
1085+
if (pointer == ~(size_t)0) {
1086+
return false;
1087+
}
1088+
#endif
10811089
dladdr_success = dladdr((void*)pointer, &dlinfo) != 0;
10821090
#endif
10831091
if (!dladdr_success || !dlinfo.dli_fname)

0 commit comments

Comments
 (0)