Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

valgrind report:"Invalid read of size 4" #506

Closed
wubo0067 opened this issue Jun 18, 2015 · 5 comments
Closed

valgrind report:"Invalid read of size 4" #506

wubo0067 opened this issue Jun 18, 2015 · 5 comments

Comments

@wubo0067
Copy link

^C==6929== Thread 1:
==6929== Invalid read of size 4
==6929== at 0x5615E4: google::protobuf::DynamicMessage::~DynamicMessage() (dynamic_message.cc:334)
==6929== by 0x561808: google::protobuf::DynamicMessage::~DynamicMessage() (dynamic_message.cc:392)
==6929== by 0x562160: google::protobuf::DynamicMessageFactory::~DynamicMessageFactory() (dynamic_message.cc:192)
==6929== by 0x42B42C: StoreSvrDBMgrModule::~StoreSvrDBMgrModule() (storesvr_dbmgr_module.cpp:21)
==6929== by 0x42B4C1: StoreSvrDBMgrModule::~StoreSvrDBMgrModule() (storesvr_dbmgr_module.cpp:22)
==6929== by 0x435C67: StoreSvrMgr::app_stop() (storesvr_mgr.cpp:106)
==6929== by 0x4350B8: fini_frame (storesvr_frame.cpp:421)
==6929== by 0x43523B: main (storesvr_main.cpp:26)
==6929== Address 0x93e236c is 44 bytes inside a block of size 240 free'd
==6929== at 0x4C2A4BC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==6929== by 0x532563: google::protobuf::DescriptorPool::Tables::~Tables() (descriptor.cc:556)
==6929== by 0x5329D9: google::protobuf::DescriptorPool::~DescriptorPool() (common.h:461)
==6929== by 0x42CF9B: StoreSvrDBMgrModule::module_fini() (storesvr_dbmgr_module.cpp:166)
==6929== by 0x435C49: StoreSvrMgr::app_stop() (storesvr_mgr.cpp:105)
==6929== by 0x4350B8: fini_frame (storesvr_frame.cpp:421)
==6929== by 0x43523B: main (storesvr_main.cpp:26)

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Jun 18, 2015

Could you provide more information here? Protobuf version, operating system, how to reproduce the problem, etc.

@wubo0067
Copy link
Author

Protobuf version: 2.5.0
OS: Ubuntu 12.04.5 LTS
Linux ubuntu 3.13.0-32-generic #57~precise1-Ubuntu SMP Tue Jul 15 03:51:20 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
perform: valgrind --leak-check=full --track-origins=yes ./yd_storesvrd --id=1.102.0.1 --conf-file=../conf/storesvr_conf.xml --routerconf-file=../../etc/routersvr/librouter_zk_conf.xml start

@wubo0067
Copy link
Author

when DynamicMessage object destructor, the valgrind will report this information

@haberman
Copy link
Member

It is very likely that you are violating one of the requirements in this paragraph:

https://github.com/google/protobuf/blob/master/src/google/protobuf/dynamic_message.h#L113

When you create a DynamicMessage, you must guarantee that the DynamicMessage is destroyed before its DynamicMessageFactory and its Descriptor.

I think you are probably destroying the Descriptor while the DynamicMessage is still alive. Then the DynamicMessage's destructor tries to read the Descriptor and gives you this error.

@wubo0067
Copy link
Author

Thanks!!

@xfxyjwf xfxyjwf closed this as completed Jan 20, 2016
taoso pushed a commit to taoso/protobuf that referenced this issue Aug 1, 2018
…-fields

protoc-gen-go: indicate deprecated fields in documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants