[
https://issues.apache.org/jira/browse/PROTON-687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14144783#comment-14144783
]
Ken Giusti commented on PROTON-687:
-----------------------------------
Thinking a bit more on this - I think my original patch was not the right
solution.
AFAIKT, the decrement that occurs when the delivery is removed from the
settled/unsettled list corresponds to the original allocation of the delivery
(remember, on allocation, the delivery's refcount is initialized to 1). So an
additional increment of the reference count when the delivery is placed on the
settled/unsettled list _should_ not be required.
What appears to be happening is the python Connection is being deleted, which
causes all children - including links and their deliveries - to be deleted.
This causes the python Delivery's _release() to be called which settles the C
delivery *but does not clear the _dlv field which references the now
deallocated C delivery object*. In addition __del__ does not check if _dlv has
been cleared before passing it to pn_delivery_set_context().
I think a proper fix would be:
diff --git a/proton-c/bindings/python/proton.py
b/proton-c/bindings/python/proton.py
index ee3701c..ce24321 100644
--- a/proton-c/bindings/python/proton.py
+++ b/proton-c/bindings/python/proton.py
@@ -2897,12 +2897,14 @@ class Delivery(object):
self.link._deliveries.add(self)
def __del__(self):
- pn_delivery_set_context(self._dlv, pn_py2void(None))
+ self._release()
def _release(self):
"""Release the underlying C Engine resource."""
if self._dlv:
+ pn_delivery_set_context(self._dlv, pn_py2void(None))
pn_delivery_settle(self._dlv)
+ self._dlv = None
@property
def tag(self):
Thoughts?
> Memory corruption in proton-test
> --------------------------------
>
> Key: PROTON-687
> URL: https://issues.apache.org/jira/browse/PROTON-687
> Project: Qpid Proton
> Issue Type: Bug
> Components: proton-c, python-binding
> Affects Versions: 0.8
> Reporter: Cliff Jansen
> Assignee: Rafael H. Schloming
> Priority: Blocker
> Attachments: segv.patch
>
>
> proton-test will fail with memory violations. Deallocated memory is
> accessed, usually with benign results but less often on Windows.
> The attached crude patch allows the bug to be "discovered" on Linux as well.
> It is not clear to me if the problem is with the swig wrapper, or whether
> this just exposes a reference counting bug in proton-c.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)