boostorg / boostorg/python

Python 3.6 + boost::python::str results in Bus error at end of Python process

Đang mở
#248 6 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C++
Star
537
Fork
223
Merge trung bình
11 giờ 22 phút
Pull request đã merge (30 ngày)
2

Mô tả

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

- CentOS Linux release 7.6.1810 (Core)
- `x86_64`
- `boost-1_69_0`
- Python 3.6 from `rh-python36-python-3.6.3-3.el7.x86_64` and Anaconda

### Source code

```c++
#include
#include

static const boost::python::str aaa("AAA BBB CCC");

boost::python::str get() {
return aaa;
}

BOOST_PYTHON_MODULE(teststr) {
using namespace boost::python;
def("get", &get);
}
```

### Compile

```
% g++ -g -DPIC -shared -fpic -o teststr.so teststr.cc -L/usr/local/boost-1_69_0-py36/lib -lboost_python36 -I/opt/rh/rh-python36/root/usr/include/python3.6m -I/usr/local/boost-1_69_0-py36/include -Wl,-rpath,/usr/local/boost-1_69_0-py36/lib
```

### Run

Prepare test python script.

```
% cat >ttt.py
import teststr
print(teststr.get())
```

```
% /opt/rh/rh-python36/root/usr/bin/python3.6m ttt.py
AAA BBB CCC
Segmentation fault (core dumped)
```

with gdb

```
% gdb /opt/rh/rh-python36/root/usr/bin/python3.6m
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-114.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
...
Reading symbols from /opt/rh/rh-python36/root/usr/bin/python3.6m...Reading symbols from /opt/rh/rh-python36/root/usr/bin/python3.6m...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Missing separate debuginfos, use: debuginfo-install rh-python36-python-3.6.3-3.el7.x86_64
(gdb) run ttt.py
Starting program: /opt/rh/rh-python36/root/usr/bin/python3.6m ttt.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
AAA BBB CCC

Program received signal SIGBUS, Bus error.
0x00007ffff6c4225e in _int_free (av=0x9094e203000000, p=0x7ffff7e97ba0,
have_lock=0) at malloc.c:3940
3940 (void)mutex_lock(&av->mutex);
(gdb) where
#0 0x00007ffff6c4225e in _int_free (av=0x9094e203000000, p=0x7ffff7e97ba0,
have_lock=0) at malloc.c:3940
#1 0x00007ffff04930c1 in boost::python::api::object_base::~object_base (
this=0x7ffff0696478 , __in_chrg=)
at /usr/local/boost-1_69_0-py36/include/boost/python/object_core.hpp:423
#2 0x00007ffff0492f90 in boost::python::api::object::~object (
this=0x7ffff0696478 , __in_chrg=)
at /usr/local/boost-1_69_0-py36/include/boost/python/object_core.hpp:238
#3 0x00007ffff049313e in boost::python::detail::str_base::~str_base (
this=0x7ffff0696478 , __in_chrg=)
at /usr/local/boost-1_69_0-py36/include/boost/python/str.hpp:28
#4 0x00007ffff049317e in boost::python::str::~str (this=0x7ffff0696478 ,
__in_chrg=)
at /usr/local/boost-1_69_0-py36/include/boost/python/str.hpp:144
#5 0x00007ffff6bfab69 in __run_exit_handlers (status=0,
listp=0x7ffff6f876c8 <__exit_funcs>,
run_list_atexit=run_list_atexit@entry=true) at exit.c:77
#6 0x00007ffff6bfabb7 in __GI_exit (status=) at exit.c:99
#7 0x00007ffff6be33dc in __libc_start_main (main=0x4009b0 , argc=2,
argv=0x7fffffffe4d8, init=, fini=,
rtld_fini=, stack_end=0x7fffffffe4c8)
at ../csu/libc-start.c:300
#8 0x0000000000400c40 in _start ()
(gdb)
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.