oracle / odpi

ODPI-C: Oracle Database Programming Interface for Drivers and Applications
https://oracle.github.io/odpi/
Other
265 stars 75 forks source link

Debug dlopen errors/successes #131

Closed tgulacsi closed 4 years ago

tgulacsi commented 4 years ago
  1. Review existing enhancement requests https://github.com/godror/godror/issues/35

  2. Describe your new request in detail Debug print failed/succeeded dlopen calls to help identify misconfigured library path search routes.

  3. Give supporting information about tools and operating systems. Give relevant product version numbers Linux

debug-dlopen.patch.txt

cjbj commented 4 years ago

Thanks @tgulacsi. I've had this kind of tracing on the wishlist for a while.

tgulacsi commented 4 years ago

For completeness sake, its not complete :-) : Linux (or POSIX)-only yet.

anthony-tuininga commented 4 years ago

First, errors are already printed with DPI_DEBUG_LEVEL=8 so that aspect is unneeded, I believe.

Second, on success the first check (using a plain dlopen()) won''t print anything useful as it will simply print "libclntsh.so" -- which we already know. The seecond check (for ORACLE_HOME) will at least print a full path, but it isn't particularly helpful, either.

That said, ideally we would be able to print the full path of the library in all cases. On Windows this is easy enough as a system call is available to figure that out. On Linux with GCC this can also be done via means of dladdr() and dlinfo() -- by enabling the GNU extensions with the macro _GNU_SOURCE. There may be other options for other platforms. If you're aware of those, that would be helpful to know. I can add a new debug level to print out this information. I don't think we want to print it all of the time.

kubo commented 4 years ago

the first check (using a plain dlopen()) won''t print anything useful as it will simply print "libclntsh.so"

dlopen() prints not only "libclntsh.so" in the following case.

  1. The symbolic link libclntsh.so is not found.
  2. libclntsh.so.18.1 is installed.
  3. However libaio.so.1, needed by libclntsh.so.18.1, is not installed.

dlopen("libclntsh.so", RTLD_LAZY) fails with "libclntsh.so: cannot open shared object file: No such file or directory". dlopen("libclntsh.so.18.1", RTLD_LAZY) fails with "libaio.so.1: cannot open shared object file: No such file or directory".

ODPI-C picks up the error message of liclntsh.so. However the error message of libclntsh.so.18.1 is useful in order to know libaio.so.1 is missing.

On Linux with GCC this can also be done via means of dladdr() and dlinfo() -- by enabling the GNU extensions with the macro _GNU_SOURCE. There may be other options for other platforms.

dladdr() is available on HP-UX, Solaris and *BSD also. I believe it came from Solaris.

anthony-tuininga commented 4 years ago

Thanks, @kubo. That's useful information. The errors that are not actually returned to the user should still be reported in the debug output. I'll look into that.

anthony-tuininga commented 4 years ago

With the latest code in the master branch, setting DPI_DEBUG_LEVEL to the value 64 will debug the loading of the Oracle Client library.

anthony-tuininga commented 4 years ago

ODPI-C 4.0 was just released containing these changes.