boostorg / boostorg/python

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

未關閉
#248 6 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
C++
星號
537
分支
223
平均合併
11 小時 22 分鐘
30 天內合併 PR
2

描述

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)
```

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

Reproduce the failure with the source shown in teststr.cc, the ttt.py script, and the provided Python 3.6 compile and run commands. Start with the gdb backtrace at boost::python::api::object_base::~object_base during process exit, then compare behavior across the listed Python versions. Done means Python 3.6 exits without the reported Bus error or segmentation fault.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
cpp, python
領域
api, backend
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。