|
From: Sato T. <tak...@gm...> - 2010-07-26 07:13:48
|
Hi,
I get the following "Invalid read error" on the part below.
103 if(counter_->decrement() == 0){
104 delete counter_;
105 if(pointee_) delete pointee_;
106 }
107 counter_ = src->counter_;
108 pointee_ = src->pointee_;
==3581== Invalid read of size 8
==3581== at 0x401625: DefaultStorage<PSPIntSLLNode,
MutexCounter>::replace(DefaultStorage<PSPIntSLLNode, MutexCounter>*)
(PSP.h:107)
==3581== by 0x401410: PSP<PSPIntSLLNode, MutexCounter,
DefaultStorage>::operator=(PSP<PSPIntSLLNode, MutexCounter,
DefaultStorage>&) (PSP.h:276)
==3581== by 0x400C49: PSPIntSLList::~PSPIntSLList() (PSPIntSLList.cpp:11)
==3581== by 0x4010FF: main (PSPIntSLList.cpp:59)
==3581== Address 0x4c24150 is 48 bytes inside a block of size 56 free'd
==3581== at 0x4A05A76: operator delete(void*) (vg_replace_malloc.c:387)
==3581== by 0x401620: DefaultStorage<PSPIntSLLNode,
MutexCounter>::replace(DefaultStorage<PSPIntSLLNode, MutexCounter>*)
(PSP.h:105)
==3581== by 0x401410: PSP<PSPIntSLLNode, MutexCounter,
DefaultStorage>::operator=(PSP<PSPIntSLLNode, MutexCounter,
DefaultStorage>&) (PSP.h:276)
==3581== by 0x400C49: PSPIntSLList::~PSPIntSLList() (PSPIntSLList.cpp:11)
==3581== by 0x4010FF: main (PSPIntSLList.cpp:59)
==3581==
==3581== Invalid read of size 8
==3581== at 0x401635: DefaultStorage<PSPIntSLLNode,
MutexCounter>::replace(DefaultStorage<PSPIntSLLNode, MutexCounter>*)
(PSP.h:108)
==3581== by 0x401410: PSP<PSPIntSLLNode, MutexCounter,
DefaultStorage>::operator=(PSP<PSPIntSLLNode, MutexCounter,
DefaultStorage>&) (PSP.h:276)
==3581== by 0x400C49: PSPIntSLList::~PSPIntSLList() (PSPIntSLList.cpp:11)
==3581== by 0x4010FF: main (PSPIntSLList.cpp:59)
==3581== Address 0x4c24148 is 40 bytes inside a block of size 56 free'd
==3581== at 0x4A05A76: operator delete(void*) (vg_replace_malloc.c:387)
==3581== by 0x401620: DefaultStorage<PSPIntSLLNode,
MutexCounter>::replace(DefaultStorage<PSPIntSLLNode, MutexCounter>*)
(PSP.h:105)
==3581== by 0x401410: PSP<PSPIntSLLNode, MutexCounter,
DefaultStorage>::operator=(PSP<PSPIntSLLNode, MutexCounter,
DefaultStorage>&) (PSP.h:276)
==3581== by 0x400C49: PSPIntSLList::~PSPIntSLList() (PSPIntSLList.cpp:11)
==3581== by 0x4010FF: main (PSPIntSLList.cpp:59)
Both of pointee_ and counter_ are member fields of the class.
This error means pointee_ and counter_ are asigned at line 107 and 108 after
deletions at line 105(104), correct?
Thanks,
Takenori
|
|
From: Bart V. A. <bva...@ac...> - 2010-07-26 07:29:26
|
On Mon, Jul 26, 2010 at 9:13 AM, Sato Takenori <tak...@gm...>wrote:
> I get the following "Invalid read error" on the part below.
>
> 103 if(counter_->decrement() == 0){
> 104 delete counter_;
> 105 if(pointee_) delete pointee_;
> 106 }
> 107 counter_ = src->counter_;
> 108 pointee_ = src->pointee_;
>
> ==3581== Invalid read of size 8
> ==3581== at 0x401625: DefaultStorage<PSPIntSLLNode,
> MutexCounter>::replace(DefaultStorage<PSPIntSLLNode, MutexCounter>*)
> (PSP.h:107)
> ==3581== by 0x401410: PSP<PSPIntSLLNode, MutexCounter,
> DefaultStorage>::operator=(PSP<PSPIntSLLNode, MutexCounter,
> DefaultStorage>&) (PSP.h:276)
> ==3581== by 0x400C49: PSPIntSLList::~PSPIntSLList()
> (PSPIntSLList.cpp:11)
> ==3581== by 0x4010FF: main (PSPIntSLList.cpp:59)
> ==3581== Address 0x4c24150 is 48 bytes inside a block of size 56 free'd
> ==3581== at 0x4A05A76: operator delete(void*) (vg_replace_malloc.c:387)
> ==3581== by 0x401620: DefaultStorage<PSPIntSLLNode,
> MutexCounter>::replace(DefaultStorage<PSPIntSLLNode, MutexCounter>*)
> (PSP.h:105)
> ==3581== by 0x401410: PSP<PSPIntSLLNode, MutexCounter,
> DefaultStorage>::operator=(PSP<PSPIntSLLNode, MutexCounter,
> DefaultStorage>&) (PSP.h:276)
> ==3581== by 0x400C49: PSPIntSLList::~PSPIntSLList()
> (PSPIntSLList.cpp:11)
> ==3581== by 0x4010FF: main (PSPIntSLList.cpp:59)
> ==3581==
> ==3581== Invalid read of size 8
> ==3581== at 0x401635: DefaultStorage<PSPIntSLLNode,
> MutexCounter>::replace(DefaultStorage<PSPIntSLLNode, MutexCounter>*)
> (PSP.h:108)
> ==3581== by 0x401410: PSP<PSPIntSLLNode, MutexCounter,
> DefaultStorage>::operator=(PSP<PSPIntSLLNode, MutexCounter,
> DefaultStorage>&) (PSP.h:276)
> ==3581== by 0x400C49: PSPIntSLList::~PSPIntSLList()
> (PSPIntSLList.cpp:11)
> ==3581== by 0x4010FF: main (PSPIntSLList.cpp:59)
> ==3581== Address 0x4c24148 is 40 bytes inside a block of size 56 free'd
> ==3581== at 0x4A05A76: operator delete(void*) (vg_replace_malloc.c:387)
> ==3581== by 0x401620: DefaultStorage<PSPIntSLLNode,
> MutexCounter>::replace(DefaultStorage<PSPIntSLLNode, MutexCounter>*)
> (PSP.h:105)
> ==3581== by 0x401410: PSP<PSPIntSLLNode, MutexCounter,
> DefaultStorage>::operator=(PSP<PSPIntSLLNode, MutexCounter,
> DefaultStorage>&) (PSP.h:276)
> ==3581== by 0x400C49: PSPIntSLList::~PSPIntSLList()
> (PSPIntSLList.cpp:11)
> ==3581== by 0x4010FF: main (PSPIntSLList.cpp:59)
>
> Both of pointee_ and counter_ are member fields of the class.
> This error means pointee_ and counter_ are asigned at line 107 and 108
> after deletions at line 105(104), correct?
>
This probably means that src is or became a dangling pointer. Have you
verified that *this and *src are different objects before freeing
this->counter_ and this->pointee_ ?
Bart.
|