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 摘要。