[OpenSmalltalk/opensmalltalk-vm] unix: use dlopen's lookup mechanism when not specifying a path (#497)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[OpenSmalltalk/opensmalltalk-vm] unix: use dlopen's lookup mechanism when not specifying a path (#497)

David Stes
 

This allows FFI modules to be specified in the same manner as you would when linking to them (-lGL --> GL, instead of /usr/lib/x86_64-linux-gnu/libGL.so as was required before this change, unless you manually placed /usr/lib/x86_64-linux-gnu in your LD_LIBRARY_PATH).

I don't know whether this will have unintended consequences for some use cases, since a lot of different systems end up calling this function. I tested the change for a while on Ubuntu 20.04 with no odd behavior occurring (but instead finally being able to load FFI modules without providing an absolute path or changing my LD_LIBRARY_PATH manually).

Some more insights on why this was necessary:
We have a long list of different ways of resolving a module. Among those is looking through the directories in the LD_LIBRARY_PATH envvar, which however only contains those directories I manually added, not all that ldconfig would consider. In our list of directories, we were already passing an empty string once, which would do nothing unless an absolute path was given, since we only proceed to look up a library if the given path is a valid directory. Providing dlopen with just a library name, without any path information, however, allows it to look through all directories as configured in ldconfig.


You can view, comment on, or merge this pull request online at:

  https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/497

Commit Summary

  • unix: use dlopen's lookup mechanism when not specifying a path

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/497", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/497", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] unix: use dlopen's lookup mechanism when not specifying a path (#497)

David Stes
 

This might be helpful to consider usable paths and might get around the problem of mismatching libraries on the search path: https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/platforms/unix/plugins/SqueakSSL/openssl_overlay.h#L471


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/497#issuecomment-626213445", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/497#issuecomment-626213445", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] unix: use dlopen's lookup mechanism when not specifying a path (#497)

David Stes
In reply to this post by David Stes
 

As well as this: https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/platforms/unix/plugins/SqueakSSL/openssl_overlay.h#L577


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/497#issuecomment-626213581", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/497#issuecomment-626213581", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] unix: use dlopen's lookup mechanism when not specifying a path (#497)

David Stes
In reply to this post by David Stes
 

@krono Hm interesting. I'm quite surprised how complex that code appears. What corner cases is it intended to catch? Is this code also invoked when linking to OpenSSL at compile time or only at runtime?

My understanding of dlopen() was that if you provide the minimal amount of information (i.e. just the library name, no paths, no .so versions), it would just go head and figure out "the right thing" for you based on the user's system configuration. But the way this looks I'd assume that my guess is quite off here :D


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/497#issuecomment-626214967", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/497#issuecomment-626214967", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] unix: use dlopen's lookup mechanism when not specifying a path (#497)

David Stes
In reply to this post by David Stes
 

My understanding of dlopen() was that if you provide the minimal amount of information (i.e. just the library name, no paths, no .so versions), it would just go head and figure out "the right thing" for you based on the user's system configuration. But the way this looks I'd assume that my guess is quite off here :D

Unless you're unlucky and it finds a library of the name you gave it but it has the wrong architecture, for example, whereas it whould have been found given the right paths. :)


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/497#issuecomment-626219593", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/497#issuecomment-626219593", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] unix: use dlopen's lookup mechanism when not specifying a path (#497)

David Stes
In reply to this post by David Stes
 

I was under the impression that dlopen would be smart enough to figure out what libraries are compatible with its caller process. Do we happen to have setups where odd behavior can be reproduced so we could try and give this code a spin in place of the more complex one that's currently in squeakssl (and also to make sure this code will keep working for FFI under such circumstances)?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/497#issuecomment-626220915", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/497#issuecomment-626220915", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] unix: use dlopen's lookup mechanism when not specifying a path (#497)

David Stes
In reply to this post by David Stes
 

Paging @eliotmiranda; he might eludicate the problems, he put all the LD_ magic in the .sh because of some of these problems.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

<script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/497#issuecomment-626222702", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/497#issuecomment-626222702", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>