Skip to content

Commit 8c8b6f0

Browse files
fingolfinKristofferC
authored andcommitted
Better Libdl.dlopen error when using non-standard extension (#46998)
When trying to dlopen a file with non-standard extension (e.g. `foo.so` instead of `foo.dylib` when running on macOS), if this failed (e.g. because of a reference to an undefined symbol), then instead of printing the error message returned by `dlerror` with a helpful notice what went wrong, a message indicating something to the effect that "foo.so.dylib was not found" was shown, which was not helpful at all. To get the actual helpful error message, add a check so that when dlopen fails for a file that actually exists, we don't retry loading from a file with the standard extension attached, which might not even exist; instead we just give up. This matches what is already being done for relative paths. This patch simply copies the relevant check to also be applied to the case dealing with absolute paths. (cherry picked from commit a490197)
1 parent b8ab6cf commit 8c8b6f0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/dlload.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ JL_DLLEXPORT void *jl_load_dynamic_library(const char *modname, unsigned flags,
259259
#ifdef _OS_WINDOWS_
260260
err = GetLastError();
261261
break; // LoadLibrary already tested the rest
262+
#else
263+
// bail out and show the error if file actually exists
264+
if (jl_stat(path, (char*)&stbuf) == 0)
265+
break;
262266
#endif
263267
}
264268

0 commit comments

Comments
 (0)