boostorg / boostorg/python

Expiring weak_ptr from python references to shared_ptr

Abierto
#189 8 comentarios 2 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
C++
Estrellas
537
Forks
223
Merge medio
11 h 22 min
PR fusionados (30 d)
2

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.