Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make dlopen more conservative about opening files the user didn't request #18061

Merged
merged 4 commits into from
Aug 18, 2016

Conversation

stevengj
Copy link
Member

I was looking at the dlopen implementation in Julia in order to document its behavior of appending the dlext (.so, .dll, or .dylib) and searching DL_LOAD_PATH, and I noticed that its attempts to search for the library path were a bit more aggressive than seemed advisable.

This patch, in addition to improving the docs, makes dlopen more conservative in the following ways:

  • dlopen("foo.dlext") no longer looks for foo.dlext.dlext (whereas it currently looks for this before foo.dlext). If the user explicitly supplies the .dlext, it seems unexpected that it would open foo.dlext.dlext instead.
  • absolute paths are never appended to other paths: dlopen("/path/to/foo") no longer searches /bar/path/to/foo where /bar is in DL_LOAD_PATH

Also, as an optimization, I changed it to only call jl_dlopen_soname (on Linux and BSD) if the library name is not an absolute path and does not have an extension, since the soname map implemented by that function only works for library names without extensions or paths.

#ifdef _OS_WINDOWS_
else if (modname[1] == ':') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, I noticed that this line was both incorrect and a potential buffer overrun if modname is an empty string. My new version checks that modname[0] is nonzero.

@JeffBezanson
Copy link
Member

LGTM.

@stevengj
Copy link
Member Author

Got The job exceeded the maximum time limit for jobs on Travis OSX ... is that a common occurrence these days? Will try restarting Travis...

@stevengj stevengj closed this Aug 17, 2016
@stevengj stevengj reopened this Aug 17, 2016
@vtjnash
Copy link
Member

vtjnash commented Aug 18, 2016

yes, that's been a common occurrence. lgtm to squash and merge.

@stevengj
Copy link
Member Author

Yay, Travis passed this time. Let's merge when AppVeyor is green.

@stevengj stevengj merged commit b506041 into JuliaLang:master Aug 18, 2016
@stevengj stevengj deleted the dlopen_path branch August 18, 2016 18:13
mfasi pushed a commit to mfasi/julia that referenced this pull request Sep 5, 2016
…uest (JuliaLang#18061)

* make dlopen more conservative about opening files the user didn't request

* update manual

* recognize \server\foo and /foo/bar absolute paths on windows, similar to isabspath

* simplify isabspath from init.c and use it in dlopen instead of duplicating
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants