Segfault-Inc / Multicorn

Data Access Library
https://multicorn.org/
PostgreSQL License
700 stars 145 forks source link

Out of Memory Errors cause core dump #254

Open rbiro opened 4 years ago

rbiro commented 4 years ago

In the event of an Out of Memory Error reportException fails at:

    PyObject   *tracebackModule = PyImport_ImportModule("traceback");
    PyObject   *format_exception = PyObject_GetAttrString(tracebackModule,"format_exception");

with a NULL pointer dereference. The problem is that without memory, python cannot load the traceback module and returns NULL. Then the attempt to get format_exception fails with a null pointer dereference and we get a core dump.

One possible solution is to load the traceback module at init time. We have implemented this, but it's on top of my other patches which I don't believe have been accepted yet.

A second possible solution is to just deal with the NULL pointer and not attempt to format the exception when the traceback module doesn't load.

For a workaround, just don't run out of memory :-).