valgrind "possibly lost" warnings?

1,766 views
Skip to first unread message

Evan Jones

unread,
Mar 31, 2010, 6:05:22 PM3/31/10
to Protocol Buffers
When I use valgrind on my programs that use protocol buffers, I get many
"possibly lost" warnings from valgrind. They all appear to be caused by
descriptor pools. I've looked at the code briefly, and I don't really
understand why these warnings happen, but I haven't tried too hard to
figure them out.

Is there any hack I could apply in order to suppress these warnings,
either in my code or in my copy of the protobuf library? Thanks,

Evan

Sample warning:


==17815== 2,004 bytes in 47 blocks are possibly lost in loss record 62 of 62
==17815== at 0x402573E: operator new(unsigned) (vg_replace_malloc.c:224)
==17815== by 0x40D7993: std::string::_Rep::_S_create(unsigned,
unsigned, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.10)
==17815== by 0x40D8407:
std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned) (in
/usr/lib/libstdc++.so.6.0.10)
==17815== by 0x40D91EE: std::string::string(std::string const&) (in
/usr/lib/libstdc++.so.6.0.10)
==17815== by 0x809F339:
google::protobuf::SimpleDescriptorDatabase::DescriptorIndex<std::pair<void
const*, int> >::AddFile(google::protobuf::FileDescriptorProto const&,
std::pair<void const*, int>) (stl_pair.h:89)
==17815== by 0x809BC73:
google::protobuf::EncodedDescriptorDatabase::Add(void const*, int)
(descriptor_database.cc:312)
==17815== by 0x806A6AF:
google::protobuf::DescriptorPool::InternalAddGeneratedFile(void const*,
int) (descriptor.cc:860)
==17815== by 0x808781E:
google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto()
(descriptor.pb.cc:599)
==17815== by 0x8087B5A:
_GLOBAL__I__ZN6google8protobuf58protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eprotoEv
(descriptor.pb.cc:644)
==17815== by 0x80C3C6C: (within
/home/evanj/hstore/hstore-async/build/protorpc/protorpcchannel_test)
==17815== by 0x804A8EF: (within
/home/evanj/hstore/hstore-async/build/protorpc/protorpcchannel_test)
==17815== by 0x80C3C08: __libc_csu_init (in
/home/evanj/hstore/hstore-async/build/protorpc/protorpcchannel_test)

--
Evan Jones
http://evanjones.ca/

Kenton Varda

unread,
Mar 31, 2010, 6:28:26 PM3/31/10
to Evan Jones, Protocol Buffers
Be sure to call ShutdownProtobufLibrary() to clean up all descriptors and such on exit:

http://code.google.com/apis/protocolbuffers/docs/reference/cpp/google.protobuf.common.html#ShutdownProtobufLibrary.details


--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.


Evan Jones

unread,
Mar 31, 2010, 9:02:03 PM3/31/10
to Protocol Buffers
On Mar 31, 2010, at 18:28 , Kenton Varda wrote:
> Be sure to call ShutdownProtobufLibrary() to clean up all
> descriptors and such on exit:

That makes my unit tests happy. Thanks!

I may add a hack to my code which does something like using atexit to
call this automatically when running under valgrind. I'm assuming that
won't cause any weird failures, but if there might be some problem
that I haven't considered, please let me know.

Evan

Kenton Varda

unread,
Mar 31, 2010, 10:25:20 PM3/31/10
to Evan Jones, Protocol Buffers
As long as you don't have background threads that might be operating on protobufs when exit() is called, that should be fine.  The shutdown code just deletes objects; nothing else.

Reply all
Reply to author
Forward
0 new messages