[ 
https://issues.apache.org/jira/browse/ARROW-7331?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16988803#comment-16988803
 ] 

Rostislav Povelikin commented on ARROW-7331:
--------------------------------------------

Hm, I've tried to load the library as ctypes.PyDLL and it works now. The 
problem was in the Gil releasing as I understood.

Can be closed

> 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
>            Priority: Minor
>
> 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)

Reply via email to