Status: New
Owner: [email protected]
Labels: Type-Defect Priority-Medium
New issue 434 by [email protected]: With
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp, parent object deleted while
child still exists: causes segmentation fault
http://code.google.com/p/protobuf/issues/detail?id=434
What steps will reproduce the problem?
1. Build c++ and python protobuf bindings for attached test.proto file.
2. Use attached setup.py file to build C++ bindings
3. Run attached test.py script
Expected output: runs and exits. Actual output: segmentation fault, or
random error (eg "KeyError: 'Field does not belong to message!'") caused by
memory corruption.
Version: protobuf-2.4.1-py2.7-linux-x86_64.egg
The problem here is that when the parent object ("a") is deleted, the c++
instance backing it is freed, and this includes all child objects. But the
child object ("b") still has a pointer into that deleted object. So when
we access it, we get a memory error.
An easy way to fix this problem would be to apply the attached patch
(proposed_fix.diff), which adds "__owner=self" to the constructor argument
list when constructing a composite property. Note that this is already
done for repeated composite properties, but it is not currently done for
simple composite properties.
This would ensure that we keep a reference to the "root" protobuf object
that actually owns the c++ structures that back the child protobuf, at
least until the child itself is deleted.
Attachments:
test.proto 73 bytes
setup.py 555 bytes
fast_test_proto.c 253 bytes
test.py 152 bytes
proposed_fix.diff 679 bytes
--
You received this message because you are subscribed to the Google Groups "Protocol
Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/protobuf?hl=en.