protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Python cpp_implementation segfaults during test

Open yingzong opened this issue 9 years ago • 3 comments

Followed instructions here for OSX: https://github.com/google/protobuf/tree/master/python

With latest version v3.2.0, got a segfault on this line of the test python setup.py test --cpp_implementation about once every two to four tries. It doesn't always happen, but when it happens it is always on this line.

testMergeFrom (google.protobuf.internal.message_test.Proto3Test) ... Segmentation fault: 11

trace from lldb:

frame #0: 0x0000000104ec52c1 _message.so`google::protobuf::python::cmessage::GetFieldDescriptor(google::protobuf::python::CMessage*, _object*) [inlined] google::protobuf::Message::GetDescriptor(this=0x00007f9132e86ad0) const + 3 at message.h:322
   319 	
   320 	  // Get a Descriptor for this message's type.  This describes what
   321 	  // fields the message contains, the types of those fields, etc.
-> 322 	  const Descriptor* GetDescriptor() const { return GetMetadata().descriptor; }
   323 	
   324 	  // Get the Reflection interface for this Message, which can be used to
   325 	  // read and modify the fields of the Message dynamically (in other words,
(lldb) up
frame #1: 0x0000000104ec52be _message.so`google::protobuf::python::cmessage::GetFieldDescriptor(self=<unavailable>, name=<unavailable>) + 14 at message.cc:986
   983 	// handling is not consistent.
   984 	static const FieldDescriptor* GetFieldDescriptor(
   985 	    CMessage* self, PyObject* name) {
-> 986 	  const Descriptor *message_descriptor = self->message->GetDescriptor();
   987 	  char* field_name;
   988 	  Py_ssize_t size;
   989 	  if (PyString_AsStringAndSize(name, &field_name, &size) < 0) {
(lldb) up
frame #2: 0x0000000104ec5381 _message.so`google::protobuf::python::cmessage::GetAttr(self=0x000000010548ac80, name=0x000000010291db48) + 65 at message.cc:2695
   2692	    return value;
   2693	  }
   2694	
-> 2695	  const FieldDescriptor* field_descriptor = GetFieldDescriptor(self, name);
   2696	  if (field_descriptor == NULL) {
   2697	    return CMessage_Type.tp_base->tp_getattro(
   2698	        reinterpret_cast<PyObject*>(self), name);

yingzong avatar Feb 15 '17 22:02 yingzong

I am also getting this exact segfault when running tests on our custom objects. I'm running v3.0.2, and we run our python tests with nosetests. Any idea what is going on?

wilstoff avatar Mar 03 '17 21:03 wilstoff

Can you give more trace information and which line of testMergeFrom() fail? I am unable to reproduce the segfault. Does all other tests always pass if comments out testMergeFrom()?

anandolee avatar Mar 23 '18 22:03 anandolee

I am closing this for clean up and unable to reproduce. Feel free to reopen if anyone can provide more detail of the failure

anandolee avatar Apr 23 '18 20:04 anandolee