{"action":"created","issue":{"url":"https://api.github.com/repos/hercules-390/hyperion/issues/256","repository_url":"https://api.github.com/repos/hercules-390/hyperion","labels_url":"https://api.github.com/repos/hercules-390/hyperion/issues/256/labels{/name}","comments_url":"https://api.github.com/repos/hercules-390/hyperion/issues/256/comments","events_url":"https://api.github.com/repos/hercules-390/hyperion/issues/256/events","html_url":"https://github.com/hercules-390/hyperion/issues/256","id":304802855,"number":256,"title":"Hercules intermittently fails to load the dyncrypt.so library at startup.","user":{"login":"srorso","id":17149494,"avatar_url":"https://avatars2.githubusercontent.com/u/17149494?v=4","gravatar_id":"","url":"https://api.github.com/users/srorso","html_url":"https://github.com/srorso","followers_url":"https://api.github.com/users/srorso/followers","following_url":"https://api.github.com/users/srorso/following{/other_user}","gists_url":"https://api.github.com/users/srorso/gists{/gist_id}","starred_url":"https://api.github.com/users/srorso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srorso/subscriptions","organizations_url":"https://api.github.com/users/srorso/orgs","repos_url":"https://api.github.com/users/srorso/repos","events_url":"https://api.github.com/users/srorso/events{/privacy}","received_events_url":"https://api.github.com/users/srorso/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2018-03-13T15:03:11Z","updated_at":"2018-03-14T18:31:53Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"This issue affects UNIX-like and macOS systems.\r\n\r\nWhen either of the following is true, Hercules will not load dyncrypt.so at startup:\r\n\r\n- Hercules is executed from the build directory and the build directory is not the current directory.\r\n\r\n- Hercules is executed from an install directory that is different from the installation directory specified at build time.  This can occur when the installation directory is moved or copied.  \r\n\r\nAn `ldmod` command specifying a correct relative or absolute path to dyncrypt.so will work.  \r\n\r\nThe issue occurs because the dynamically loaded module table entry for dyncrypt.so includes a subdirectory and a \"/\" (`crypto/dyncrypt`) in the file name.  When a file name passed to dlopen() includes a \"/\", dlopen assumes a path and searches only that path for the file.  RPATH and RUNPATH in the calling module, the LD_LIBRARY_PATH variable, and other locations are not searched.  \r\n\r\nThis behavior is required by The Open Group Base Specifications Issue 6 and 7, IEEE Std. 1003.1 2004, 2008, and 2016; see:\r\n\r\n  http://pubs.opengroup.org/onlinepubs/9699919799/functions/dlopen.html\r\n\r\nThis issue has been reproduced on Hyperion built with CMake and with GNU autotools.  \r\n\r\nFunction hld_load() in hdl.c looks in four places for a module to be pre-loaded.  As soon as the module is found, searching stops.  Because the preload entry for dyncrypt includes a slash, RPATH, RUNPATH, LD_LIBRARY_PATH, /usr/lib, and /lib are not searched.  \r\n\r\n1. Search the current working directory for \\<modulename>\r\n2. Search the current working directory for \\<modulename>.so  (Note 1)\r\n3. Search the install prefix specified at build time for \\<modulename>  (Notes 2, 3)\r\n4. Search the install prefix specified at build time for \\<modulename>.so (Notes 1, 2. 3)\r\n\r\n**Note 1:**  .so is the appropriate suffix for UNIX-like and macOS systems. \r\n\r\n**Note 2:** The install prefix is suffiixed with 'lib'; an install prefix of /home/srorso/herc causes /home/srorso/herc/lib to be searched.  \r\n\r\n**Note 3:** The install prefix directory is searched _even when Hercules is run from the build directory_.  This creates the possibility that Hercules, when run from the build directory, would use  a back-level dyncrypt module from a previously populated install directory.  \r\n\r\nDevice driver and other modules are not affected by this issue because their names do not include a \"/\", with the effect that dlopen() will search RUNPATH/RPATH.  \r\n\r\nA possible solution is to a) remove the subdirectory from the preload table entry for dyncrypt in hdl.c and b) include crypto in the RPATH/RUNPATH for both build and install.\r\n\r\nA simpler and I feel better long term solution would be to just a) remove the subdirectory from the preload table entry for dyncrypt and b) build and install the crypto library in the Hercules library directory.  But this introduces a source-build compatibility issue between the GNU-autotools build and the CMake build, and I dread putting in something like #ifdef CMAKEBUILD.  \r\n\r\nIssues loading crypto have bedeviled me for quite a while.  I think I now understand it.  \r\n\r\nBest Regards,\r\nSteve Orso"},"comment":{"url":"https://api.github.com/repos/hercules-390/hyperion/issues/comments/373129021","html_url":"https://github.com/hercules-390/hyperion/issues/256#issuecomment-373129021","issue_url":"https://api.github.com/repos/hercules-390/hyperion/issues/256","id":373129021,"user":{"login":"jphartmann","id":1812435,"avatar_url":"https://avatars0.githubusercontent.com/u/1812435?v=4","gravatar_id":"","url":"https://api.github.com/users/jphartmann","html_url":"https://github.com/jphartmann","followers_url":"https://api.github.com/users/jphartmann/followers","following_url":"https://api.github.com/users/jphartmann/following{/other_user}","gists_url":"https://api.github.com/users/jphartmann/gists{/gist_id}","starred_url":"https://api.github.com/users/jphartmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jphartmann/subscriptions","organizations_url":"https://api.github.com/users/jphartmann/orgs","repos_url":"https://api.github.com/users/jphartmann/repos","events_url":"https://api.github.com/users/jphartmann/events{/privacy}","received_events_url":"https://api.github.com/users/jphartmann/received_events","type":"User","site_admin":false},"created_at":"2018-03-14T18:31:52Z","updated_at":"2018-03-14T18:31:52Z","author_association":"CONTRIBUTOR","body":"So why don't you shut up, Ivan.  You offer no insight and no solutions."}}
{"actor":{"display_login":"jphartmann"}}