Segmentation fault in Python 3 - Cursor - chained exceptions

Boris Dzuba <[email protected]>
Newsgroups gmane.comp.python.db.cx-oracle
Message-ID <CANi+SedO7=L3rdXY3Gj5cdR5BusYm1=oR503uFQo+qSoBeQ=UA@mail.gmail.com>
Hi all,

The following test program gives a segmentation fault:

C:\>python
Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>> c=cx_Oracle.connect(<connect string>).cursor()
>>> try:
...     c.execute("select")
... except:
...     try:
...             c.execute("select")
...     except:
...             pass
...

C:\>

Access Violation
Faulting application name: python.exe
Fault offset: 0x000000000000cacd


Platform: 64bit, Win7, Oracle Client 11g (11.2.0.1.0), python 3.3.3,
cx_Oracle 5.1.2



At a guess, the problem is because in the function Cursor_SetErrorOffset()
/Cursor.c/:

static void Cursor_SetErrorOffset(
    udt_Cursor *self)                   // cursor to get the error offset
from
{
    PyObject *type, *value, *traceback;
    udt_Error *error;

    PyErr_Fetch(&type, &value, &traceback);
    if (type == g_DatabaseErrorException) {
        error = (udt_Error*) value;
        OCIAttrGet(self->handle, OCI_HTYPE_STMT, &error->offset, 0,
                OCI_ATTR_PARSE_ERROR_OFFSET,
self->environment->errorHandle);
    }
    PyErr_Restore(type, value, traceback);
}

OCIAttrGet() call attempts to write a value to the address
/&error->offset/,
therefore after the end of an allocated memory block of the borrowed
pointer /PyObject *value/

typedef struct {
    PyObject_HEAD
    sb4 code;
    ub4 offset;
    PyObject *message;
    const char *context;
} udt_Error;


Commenting it out /* OCIAttrGet(self->handle, OCI_HTYPE_STMT,
&error->offset, 0, OCI_ATTR_PARSE_ERROR_OFFSET,
self->environment->errorHandle);*/
fix this crash!


Regards,
Boris

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs

_______________________________________________
cx-oracle-users mailing list
cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/cx-oracle-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.