New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python 3.6 + boost::python::str results in Bus error at end of Python process #248
Comments
I've got the same bug with python 3.7 and boost-1.69:
Python is compiled from sources (3.7.2) on Fedora 29 and boost is compiled from sources too. |
I couldn't reproduce the problem with python-3.7.4 and boost-1.71.0 anymore. #include <boost/python.hpp>
#include <boost/python/str.hpp>
using namespace boost::python;
class teststr3 {
public:
static list aaa_list;
static const str aaa1;
static const str aaa2;
teststr3()
{
aaa_list.append(aaa1);
aaa_list.append(aaa2);
}
str get(int i) {
if (i==1) {
return aaa1;
} else {
return aaa2;
}
}
};
list teststr3::aaa_list;
const str teststr3::aaa1("1 AAA BBB CCC");
const str teststr3::aaa2("2 AAA BBB CCC");
BOOST_PYTHON_MODULE(teststr3) {
using namespace boost::python;
class_<teststr3>("teststr3")
.def("get", &teststr3::get);
}
/*
g++ -g -DPIC -shared -fpic -o teststr3.so teststr3.cc -L/usr/local/boost-1_71_0-py374/lib -lboost_python37 -I/usr/local/python374/include/python3.7dm -I/usr/local/boost-1_71_0-py374/include -Wl,-rpath,/usr/local/boost-1_71_0-py374/lib
*/
|
With python-3.7.5(debug build) and GDB, I tried step execution. Python-3.7.5/Objects/listobject.c static void
list_dealloc(PyListObject *op)
{
Py_ssize_t i;
PyObject_GC_UnTrack(op);
Py_TRASHCAN_SAFE_BEGIN(op) // <--- SIGSEGV here!! The macro definition is #define Py_TRASHCAN_SAFE_BEGIN(op) \
do { \
PyThreadState *_tstate = PyThreadState_GET(); \
if (_tstate->trash_delete_nesting < PyTrash_UNWIND_LEVEL) { \
++_tstate->trash_delete_nesting;
/* The body of the deallocator is here. */
So, |
A patch on python which has worked for me on Python-3.6.7 (works also for other versions, but you need to adapt it):
This is a workaround and not a fix ... |
If possible, I need a workaround at the side of boost.python, not Python. Though, Python's issue, https://bugs.python.org/issue17703 |
I opened an issue at Python Bug Tracker, |
On Python 3.6, when boost::python::str constructor is used at global scope, I receive "Bus error" at end of python process.
Python 3.4 and 3.5 worked fine, no errors.
My environment
x86_64
boost-1_69_0
rh-python36-python-3.6.3-3.el7.x86_64
and AnacondaSource code
Compile
Run
Prepare test python script.
with gdb
The text was updated successfully, but these errors were encountered: