Skip to content

Commit 7f27dea

Browse files
authored
Fix Base.StackTraces.lookup(C_NULL - 1) on macOS 12 (#43612)
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 b0fbc5c commit 7f27dea

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
@@ -1094,6 +1094,14 @@ bool jl_dylib_DI_for_fptr(size_t pointer, object::SectionRef *Section, int64_t *
10941094
struct link_map *extra_info;
10951095
dladdr_success = dladdr1((void*)pointer, &dlinfo, (void**)&extra_info, RTLD_DL_LINKMAP) != 0;
10961096
#else
1097+
#ifdef _OS_DARWIN_
1098+
// On macOS 12, dladdr(-1, …) succeeds and returns the main executable image,
1099+
// despite there never actually being an image there. This is not what we want,
1100+
// as we use -1 as a known-invalid value e.g. in the test suite.
1101+
if (pointer == ~(size_t)0) {
1102+
return false;
1103+
}
1104+
#endif
10971105
dladdr_success = dladdr((void*)pointer, &dlinfo) != 0;
10981106
#endif
10991107
if (!dladdr_success || !dlinfo.dli_fname)

0 commit comments

Comments
 (0)