You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The environment property of the PyAbstract1 objects causes my Python program to crash with a segmentation fault (and even my Python debugger when inspecting such objects).
Here is a minimalist version that should go wrong on any computer:
import gc
from apronpy.var import PyVar
from apronpy.environment import PyEnvironment
from apronpy.box import PyBoxMPQManager
from apronpy.abstract1 import PyAbstract1
env = PyEnvironment([PyVar('x')])
man = PyBoxMPQManager()
abs_value = PyAbstract1.top(man, env)
inner_env_A = abs_value.environment
inner_env_B = abs_value.environment
inner_env_C = abs_value.environment
del inner_env_A
del inner_env_B
del inner_env_C # Fails with SIGSEGV or double free or invalid pointer
gc.collect() # Just to be sure that __del__ was called
Is it a bug ?
Note that this program does not use the APRON ctypes directly but uses only their Python proxies (Py*). In my humble opinion, this should not end with a segmentation fault.
Fix suggestion
I guess that this problem is triggered by the code of the environment property of the PyAbstract1 class. This code builds a PyEnvironment without increment of the APRON environment reference counter but eventually triggers a decrement through the __del__ method of the newly created PyEnvironment.
Adding the increment in the PyEnvironment constructor or in the environment property fixes this issue. I would not swear that these fixes are sound and memory-leak free...
Improvement suggestion
In passing, it would be nice that the Py*1 classes could all offer a way of retrieving the underlying environment as a PyEnvironment object.
The text was updated successfully, but these errors were encountered:
Thanks, good catch! I will implement your improvement suggestion as soon as I have a moment. It's delicate to do, to avoid memory leaks or segmentation faults.
Hello Caterina,
The
environment
property of thePyAbstract1
objects causes my Python program to crash with a segmentation fault (and even my Python debugger when inspecting such objects).Here is a minimalist version that should go wrong on any computer:
Is it a bug ?
Note that this program does not use the APRON ctypes directly but uses only their Python proxies (
Py*
). In my humble opinion, this should not end with a segmentation fault.Fix suggestion
I guess that this problem is triggered by the code of the
environment
property of thePyAbstract1
class. This code builds aPyEnvironment
without increment of the APRON environment reference counter but eventually triggers a decrement through the__del__
method of the newly createdPyEnvironment
.Adding the increment in the
PyEnvironment
constructor or in theenvironment
property fixes this issue. I would not swear that these fixes are sound and memory-leak free...Improvement suggestion
In passing, it would be nice that the
Py*1
classes could all offer a way of retrieving the underlying environment as aPyEnvironment
object.The text was updated successfully, but these errors were encountered: