boostorg / boostorg/python

Expiring weak_ptr from python references to shared_ptr

Đang mở
#189 8 bình luận 2 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ả

Today I stumbled upon the issue described [here](https://stackoverflow.com/questions/8233252/boostpython-and-weak-ptr-stuff-disappearing), and since I could not find any related issues in the tracker, I thought to add one. That stackoverflow post is very complete, but I have experimenting myself for a while, so I am attaching my own [test](https://github.com/boostorg/python/files/1794626/ptr_test.zip) to this issue.

There is only one minor difference to note between my test and that stackoverflow post: I used C++14 (gcc) with `weak_ptr` and `shared_ptr` from the standard library, as opposed to the boost equivalents.

Apart from that, one curious thing I noticed is that, if I use boost 1.58 as installed from my Ubuntu repos, it _does_ work as expected; whereas, if I use the newer boost 1.66, it does not. That is, if we change the first line in the attached `build.sh` to the following:
```
# removed -I/opt/boost-1.66/include
g++ -c -std=gnu++1y -fPIC -o main.o main.cpp -I/usr/include/python2.7
```
then the pointers do not expire. So the bug might have been fixed in the past, and could have somehow re-emerged.

For completeness, here are my system specs. I am happy to share more info as required!
```
matteo@ubuntu:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.4 LTS"

matteo@ubuntu:~$ gcc --version
gcc (Ubuntu 5.4.1-2ubuntu1~16.04) 5.4.1 20160904
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

matteo@ubuntu:~$ dpkg -s libboost-dev | grep 'Version'
Version: 1.58.0.1ubuntu1

matteo@ubuntu:~$ cat /opt/boost-1.66/include/boost/version.hpp | grep "BOOST_LIB_VERSION"
// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
#define BOOST_LIB_VERSION "1_66"
```

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.