You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Rostislav Povelikin (Jira)" <ji...@apache.org> on 2019/12/05 13:09:00 UTC

[jira] [Created] (ARROW-7331) Segmentation fault on import_arrow from loaded to Python .so library

Rostislav Povelikin created ARROW-7331:
------------------------------------------

             Summary: Segmentation fault on import_arrow from loaded to Python .so library
                 Key: ARROW-7331
                 URL: https://issues.apache.org/jira/browse/ARROW-7331
             Project: Apache Arrow
          Issue Type: Bug
         Environment: Ubuntu 16.04, g++7.4.0, 0.14.0 PyArrow
            Reporter: Rostislav Povelikin


Let's consider the following .cpp file:
{code:cpp}
// file.cpp
#include "file.h"
#include <iostream>
#include <Python.h>
#include <arrow/python/pyarrow.h>

extern "C" void process() {
    Py_Initialize();
    int import_status = arrow::py::import_pyarrow();
    std::cout << "Import status\t" << import_status << std::endl;
    Py_Finalize();
}
{code}
I compiled it as:
{code:java}
g++ -D_GLIBCXX_USE_CXX11_ABI=0 ./file.cpp -fPIC -shared -o libshared.so -I$PYARROW_HOME/include -I$PYTHON_INCLUDE -larrow -larrow_python -lpython3.6m
{code}
And getting a nice shared library which I even can load and execute:
{code:cpp}
#include "file.h"

int main() {
    process();
    return 0;
}
{code}
With an expected result:
{code:java}
 Import status   0 {code}
So it really works!

Now I want to load the same library and call it from Python:
{code:python}
import ctypes

lib = ctypes.cdll.LoadLibrary("./libshared.so")
lib.process()
{code}
And here I am getting the segmentation fault.

Okay, I removed Py_Finalize(), cout and import_pyarrow() - it works good, calling Py_Initialize().
 Get back import_pyarrow() - segmentation fault.

How can I execute such function properly?

How can I found what really happens?
 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)