Skip to content

cx_Oracle.connect segfaults when using python-ldap #187

@EricHorton

Description

@EricHorton

cx_Oracle.connect segfaults when using LDAP directory services and python-ldap is imported.

To reproduce, configure a Python environment

python3 -m venv env/
. env/bin/activate
pip install cx-oracle==6.3.1 python-ldap==3.1.0

and try to establish a connection

import cx_Oracle
import ldap

cx_Oracle.connect(user='username', password='password', dsn='<dsn>')

The above exits immediately with Segmentation fault: 11. Note that <dsn> must be valid (it must exist and be discoverable from directory services), otherwise the module will exit normally, saying the connect identifier could not be resolved.

The error appears to be where Oracle searches for LDAP entries, passing a bad memory reference to ldap_first_entry. From the lldb backtrace:

$ lldb python
(lldb) target create "python"
Current executable set to 'python' (x86_64).
(lldb) run test.py

...

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
  * frame #0: 0x00007fff586d6e6e LDAP`ldap_first_entry + 12
    frame #1: 0x000000010407c7d6 libclntsh.dylib`nnflgne + 3526
...

Relevant Questions

  1. What is your version of Python? Is it 32-bit or 64-bit?

64-bit Python 3.6.5, installed via Homebrew with brew install python.

  1. What is your version of cx_Oracle?

From pip freeze

cx-Oracle==6.3.1
pyasn1==0.4.3
pyasn1-modules==0.2.1
python-ldap==3.1.0
  1. What is your version of the Oracle client (e.g. Instant Client)? How was it
    installed? Where is it installed?

Oracle Instant Client Basic 12.1, installed via Homebrew at /usr/local/Cellar/instantclient-basic/. Installation performed by manually downloading Instant Client .zip file, placing it in ~/Library/Caches/Homebrew, and running

brew tap InstantClientTap/instantclient
brew install instantclient-basic
  1. What is your version of the Oracle Database?

N/A (issue occurs prior to connecting to a database)

  1. What is your OS and version?

macOS 10.13.3

  1. What compiler version did you use? For example, with GCC, run
    gcc --version.

Apple LLVM version 9.1.0 (clang-902.0.39.2)

  1. What environment variables did you set? How exactly did you set them?

Shell startup script with

export ORACLE_HOME=/usr/local/Cellar/instantclient-sqlplus/12.2.0.1.0-2/
  1. Other software versions.

OpenLDAP 2.4.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions