From: branan@... Date: 2017-08-08T16:32:10+00:00 Subject: [ruby-core:82283] [Ruby trunk Bug#13788] libruby.so cannot be loaded by another program when --enable-load-relative is used Issue #13788 has been updated by branan (Branan Riley). It appears from the comment on `ruby_sysinit` that programs embedding ruby should NOT be calling it under normal usage: /*! Initializes the process for ruby(1). * * This function assumes this process is ruby(1) and it has just started. * Usually programs that embeds CRuby interpreter should not call this function, * and should do their own initialization. */ Further, looking at the logic in `dladdr_path`, it appears to boil down to: * if we are a statically-linked ruby executable, lookup our libpath from `/proc/self/exe` * else, lookup our libpath from the `Dl_info` struct If my interpretation of that logic is correct, it would not make sense for `origarg` to be set when embedding the ruby interpreter. We'd expect to fall through to the second case: looking up the libpath from where the ruby shared library is located. All that aside, since there is a reasonable behavior if `origarg.argv` is NULL (using the `Dl_info` struct), I would expect the function to handle that case and allow the program to continue, instead of segfaulting. ---------------------------------------- Bug #13788: libruby.so cannot be loaded by another program when --enable-load-relative is used https://bugs.ruby-lang.org/issues/13788#change-66071 * Author: branan (Branan Riley) * Status: Feedback * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- --enable-load-relative causes `dladdr_path` in ruby.c to be called. This function assumes that `origarg` is set, but that global will only be set if `ruby_sysinit` is called. Normally that is done by the `ruby` executable, but not by other programs that embed the ruby interpreter. The attached patch causes `dladdr_path` to check that `origarg` is set, before trying to access the data in it. ---Files-------------------------------- origarg.patch (390 Bytes) -- https://bugs.ruby-lang.org/ Unsubscribe: