Skip to content

Commit

Permalink
Better Libdl.dlopen error when using non-standard extension (#46998)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
fingolfin authored and staticfloat committed Dec 22, 2022
1 parent c396015 commit ca561ce
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/dlload.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ JL_DLLEXPORT void *jl_load_dynamic_library(const char *modname, unsigned flags,
#ifdef _OS_WINDOWS_
err = GetLastError();
break; // LoadLibrary already tested the rest
#else
// bail out and show the error if file actually exists
if (jl_stat(path, (char*)&stbuf) == 0)
break;
#endif
}

Expand Down

0 comments on commit ca561ce

Please sign in to comment.