boostorg / boostorg/python

Expiring weak_ptr from python references to shared_ptr

未关闭
#189 8 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C++
星标
537
派生
223
平均合并
11 小时 22 分钟
30 天内合并 PR
2

描述

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

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。