Inadvertent Oracle dylib library linking
Inadvertent Oracle dylib library linking
- Subject: Inadvertent Oracle dylib library linking
- From: Wade Williams <email@hidden>
- Date: Mon, 04 Mar 2013 07:53:07 -0600
There's a widely-used Ruby gem (ruby-oci8) which uses a C-extension to call an Oracle C library (Oracle Instant Client). It creates a bundle (oci8lib_191.bundle) which calls routines in the the Oracle library (libclntsh.dylib.11.1).
However, if one uses LDAP to resolve their database name, there's a problem. The client crashes with:
> Assertion failed: (LDAP_VALID( ld )), function ldap_first_entry, file getentry.c, line 35.
The Oracle library includes its own LDAP routines.
> nm /Applications/OracleInstantClient/libclntsh.dylib.11.1 | grep ldap_first_entry
> 0000000000f0fc50 T _ldap_first_entry
> 0000000000f15620 T _ora_ldap_first_entry
However, I've verified using gdb that when the client crashes, it crashes inside the code for the OS X LDAP library.
(gdb) bt
#0 0x00007fff8403d212 in __pthread_kill ()
#1 0x00007fff8da78af4 in pthread_kill ()
#2 0x00007fff8dabcdce in abort ()
#3 0x00007fff8dabde2a in __assert_rtn ()
#4 0x00007fff86e233e2 in ldap_first_entry ()
(gdb) info symbol 0x00007fff86e233e2
ldap_first_entry + 98 in section LC_SEGMENT.__TEXT.__text of /System/Library/Frameworks/LDAP.framework/Versions/A/LDAP
So, apparently what is happening is when the bundle tries to call ldap_first_entry(), it's linked with the OS X version instead of Oracle's custom version inside (libclntsh.dylib.11.1).
My first thought was to use the same trick used to link a static library when a dynamic library is present. That is, pass the absolute path to the library. However, as you can see, that results in an error (the library does exists
gcc -dynamic -bundle -o oci8lib_191.bundle oci8lib.o env.o error.o oci8.o ocihandle.o connection_pool.o stmt.o bind.o metadata.o attr.o lob.o oradate.o ocinumber.o ocidatetime.o object.o apiwrap.o encoding.o oranumber_util.o thread_util.o -L. -L/usr/local/lib -L. -L/usr/local/lib -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace -L/Applications/OracleInstantClient -l/Applications/OracleInstantClient/libclntsh.dylib.11.1 -lpthread -ldl -lobjc
ld: library not found for -l/Applications/OracleInstantClient/libclntsh.dylib.11.1
The library does exist at the path listed:
> xanadu:~ wwilliam$ file /Applications/OracleInstantClient/libclntsh.dylib.11.1
> /Applications/OracleInstantClient/libclntsh.dylib.11.1: Mach-O 64-bit dynamically linked shared library x86_64
FYI, DYLD_LIBRARY_PATH is set:
> DYLD_LIBRARY_PATH=:/Applications/OracleInstantClient
So, how can ensure the bundle links with the Oracle version of ldap_first_entry ()?
I'm using OS X 10.8.2 with Xcode Version 4.6 (4H127).
Any thoughts appreciated.
Wade
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden