oracle / python-cx_Oracle

Python interface to Oracle Database now superseded by python-oracledb
https://oracle.github.io/python-cx_Oracle
Other
888 stars 361 forks source link

Crash when using bool values as query parameters with cx_Oracle 6.0rc1 and Oracle Client 11.2 #49

Closed mlafon closed 7 years ago

mlafon commented 7 years ago

_Initial note: I'm unsure if this is a valid usage but this was working with cxOracle 5.3 and (very) old versions of Django seems to trigger that bug.

The crash is triggered by providing a boolean value as a query parameter with Oracle Client 11.2.

$ gdb python
[...]
(gdb) run
Starting program: /usr/bin/python 
[...]
>>> import cx_Oracle
>>> cx_Oracle.version
'6.0rc1'
>>> cx_Oracle.clientversion()
(11, 2, 0, 4, 0)
>>> connection = cx_Oracle.Connection('...')
>>> connection.cursor().execute('SELECT * FROM TABLENAME WHERE TABLENAME.ARG = :arg0', [True])

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff3e115d2 in kpubsuuc () from /usr/lib/oracle/11.2/client64/lib/libclntsh.so.11.1
(gdb) bt
#0  0x00007ffff3e115d2 in kpubsuuc () from /usr/lib/oracle/11.2/client64/lib/libclntsh.so.11.1
#1  0x00007ffff3e114a7 in kpubndp () from /usr/lib/oracle/11.2/client64/lib/libclntsh.so.11.1
#2  0x00007ffff3e10b54 in kpubndp0 () from /usr/lib/oracle/11.2/client64/lib/libclntsh.so.11.1
#3  0x00007ffff3dede87 in OCIBindByPos () from /usr/lib/oracle/11.2/client64/lib/libclntsh.so.11.1
#4  0x00007ffff633a4ba in dpiOci__bindByPos (stmt=0xaa1720, bindHandle=0x7fffffffd6c0, pos=1, 
    dynamicBind=<optimized out>, var=<optimized out>, error=0x7fffffffd720) at odpi/src/dpiOci.c:683
#5  0x00007ffff6354d8e in dpiStmt__bind (stmt=stmt@entry=0xaa1720, var=var@entry=0xaa17e0, 
    addReference=addReference@entry=1, pos=pos@entry=1, name=name@entry=0x0, nameLength=nameLength@entry=0, 
    error=0x7fffffffd720) at odpi/src/dpiStmt.c:149
#6  0x00007ffff63551c7 in dpiStmt_bindByPos (stmt=0xaa1720, pos=pos@entry=1, var=0xaa17e0) at odpi/src/dpiStmt.c:1036
#7  0x00007ffff6355391 in Variable_Bind (var=<optimized out>, cursor=0x7ffff7e92cb0, cursor=0x7ffff7e92cb0, pos=1, 
    name=0x0) at src/Variable.c:677
#8  Cursor_PerformBind (self=0x7ffff7e92cb0) at src/Cursor.c:866
#9  0x00007ffff635a63a in Cursor_Execute (self=0x7ffff7e92cb0, args=<optimized out>, keywordArgs=<optimized out>)
    at src/Cursor.c:1415
#10 0x00000000004c468a in PyEval_EvalFrameEx ()
#11 0x00000000004c2765 in PyEval_EvalCodeEx ()
#12 0x00000000004c2509 in PyEval_EvalCode ()
#13 0x00000000004f1def in ?? ()
#14 0x000000000044c6ed in PyRun_InteractiveOneFlags ()
#15 0x000000000044c4b2 in PyRun_InteractiveLoopFlags ()
#16 0x000000000042e88a in ?? ()
#17 0x000000000049e14a in Py_Main ()
#18 0x00007ffff7810830 in __libc_start_main (main=0x49dab0 <main>, argc=1, argv=0x7fffffffdd88, init=<optimized out>, 
    fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdd78) at ../csu/libc-start.c:291
#19 0x000000000049d9d9 in _start ()

Using cx_Oracle 5.3:

$ python
[...]
>>> import cx_Oracle
>>> cx_Oracle.version
'5.3'
>>> cx_Oracle.clientversion()
(11, 2, 0, 4, 0)
>>> connection = cx_Oracle.Connection('...')
>>> c = connection.cursor().execute('SELECT * FROM TABLENAME WHERE TABLENAME.ARG = :arg0', [True])
>>> c.fetchall()
[(... result ...)]
>>> c.bindvars
[<cx_Oracle.NUMBER with value True>]

When using Oracle Client 12.x, the ORA-03115 (unsupported network datatype or representation) error is raised instead.

Answer the following questions:

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

Same behaviour with 32-bit or 64-bit

  1. What is your version of cx_Oracle?

6.0rc1

  1. What is your version of the Oracle client (e.g. Instant Client)? How was it installed? Where is it installed?

11.2.0.4.0. Installed from Oracle RPM

  1. What is your version of the Oracle Database?

11.2.0.1.0

  1. What is your OS and version?

Ubuntu 16.04, CentOS 7

  1. What compiler version did you use? For example, with GCC, run gcc --version.
  1. What environment variables did you set? How exactly did you set them?

PYTHONPATH and LD_LIBRARY_PATH are set to correctly load the expected libraries.

  1. What exact command caused the problem (e.g. what command did you try to install with)? Who were you logged in as?

See above

  1. What error(s) you are seeing?

See above

anthony-tuininga commented 7 years ago

This is a known issue with rc1. It was corrected by this commit: https://github.com/oracle/python-cx_Oracle/commit/628d1717f5f622fc86cbd30278c28fdc7db9bd37. A new release candidate should be coming out in the next few days.

mlafon commented 7 years ago

Oh, sorry for not having checked that first. I confirm this is working on master.

Thanks for your work and quick reply. Waiting for the next rc.