Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

purify error with std::string, -xarch=v8plusa -mt

807575Feb 18 2003 — edited Apr 15 2003

Using WS6U2, latest patches, on Solaris 8 with latest patch cluster (as of a few days ago):

string.cpp:
#include <string>

using namespace std;

int main(int argc, char * argv[])
{

   string val1 = "hello";
   string val2 = "world";

   string copy( val1 );
   copy = val2;
  
   return 0;

}
CC -V
CC: Sun WorkShop 6 update 2 C++ 5.3 Patch 111685-12 2002/12/16
purify -version
Version 2002a.06.00 Solaris 2
purify -always-use-cache-dir -cache-dir=`pwd`/cache CC -g -xarch=v8plusa -mt string.cpp -o string
And we get some rather nasty errors: three Free Memory Reads, two Free Memory Writes, and one Freeing Unallocated Memory. However, remove either of the "-mt" or "-xarch=v8plusa" options, and all is well - no memory errors at all. So it seems that this problem only affects the multithreaded v8plusa specific implementation of std::string.

In the case where it fails ("-mt -xarch=v8plusa"), purify complains as follows:

**** Purify instrumented string (pid 13888 at Tue Feb 18 16:42:31 2003)
* Purify 2002a.06.00 Solaris 2 (32-bit) Copyright (C) 1992-2002 Rational Software Corp. All rights reserved.
* For contact information type: "purify -help"
* For TTY output, use the option "-windows=no"
* Command-line: ./string
* Options settings: -max-threads=2500 -follow-child-processes=yes \
-leaks-at-exit=yes -chain-length=16 -report-pmrs=yes -threads=yes -purify \
-always-use-cache-dir \
-cache-dir=/home/rational/src/experiments/string/cache \
-purify-home=/usr/local/software/rational/releases/purify.sol.2002a.06.00 \
-threads=yes -use-internal-locks=yes -thread_stack_change=0x4000 \
-mt_safe_malloc=yes
* License successfully checked out.
* Command-line: ./string

**** Purify instrumented string (pid 13888) ****
FMR: Free memory read:
* This is occurring while in:
long __rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> >::__references()const [string_ref:193]
void std::basic_string<char,std::char_traits<char>,std::allocator<char> >::__unLink() [string:913]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string() [string:297]
main [string.cpp:15]
_start [crt1.o]
* Reading 4 bytes from 0xa6d30 in the heap.
* Address 0xa6d30 is 24 bytes into a freed block at 0xa6d18 of 47 bytes.
* This block was allocated from:
malloc [rtlib.o]
c2n6Fi_Pv___1 [libCrun.so.1]
void*operator new(unsigned) [rtlib.o]
__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> >*std::basic_string<char,std::char_traits<char>,std::allocator<char> >::__getRep(unsigned,unsigned) [libCstd.so.1]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string(const char*,const std::allocator<char>&) [libCstd.so.1]
main [string.cpp:9]
_start [crt1.o]
* There have been 0 frees since this block was freed from:
free [rtlib.o]
c2k6FPv_v___1 [libCrun.so.1]
void operator delete(void*) [rtlib.o]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >&std::basic_string<char,std::char_traits<char>,std::allocator<char> >::operator=(const std::basic_string<char,std::char_traits<char>,std::allocator<char> >&) [libCstd.so.1]
main [string.cpp:13]
_start [crt1.o]

**** Purify instrumented string (pid 13888) ****
FMR: Free memory read:
* This is occurring while in:
pthread_mutex_destroy [libthread.so.1]
RWSTDMutex::~RWSTDMutex() [stdmutex.h:167]
__rwstd::__string_ref_rep<std::allocator<char> >::~__string_ref_rep #Nvariant 1() [string.cpp]
__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> >::~__string_ref() [string.cpp]
void __rwstd::__destroy<__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> > >(__type_0*) [memory:177]
void std::allocator_interface<std::allocator<char>,__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> > >::destroy(__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> >*) [memory:513]
void std::basic_string<char,std::char_traits<char>,std::allocator<char> >::__unLink() [string:915]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string() [string:297]
main [string.cpp:15]
_start [crt1.o]
* Reading 2 bytes from 0xa6d18 in the heap.
* Address 0xa6d18 is at the beginning of a freed block of 47 bytes.
* This block was allocated from:
malloc [rtlib.o]
c2n6Fi_Pv___1 [libCrun.so.1]
void*operator new(unsigned) [rtlib.o]
__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> >*std::basic_string<char,std::char_traits<char>,std::allocator<char> >::__getRep(unsigned,unsigned) [libCstd.so.1]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string(const char*,const std::allocator<char>&) [libCstd.so.1]
main [string.cpp:9]
_start [crt1.o]
* There have been 0 frees since this block was freed from:
free [rtlib.o]
c2k6FPv_v___1 [libCrun.so.1]
void operator delete(void*) [rtlib.o]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >&std::basic_string<char,std::char_traits<char>,std::allocator<char> >::operator=(const std::basic_string<char,std::char_traits<char>,std::allocator<char> >&) [libCstd.so.1]
main [string.cpp:13]
_start [crt1.o]

**** Purify instrumented string (pid 13888) ****
FMW: Free memory write:
* This is occurring while in:
pthread_mutex_destroy [libthread.so.1]
RWSTDMutex::~RWSTDMutex() [stdmutex.h:167]
__rwstd::__string_ref_rep<std::allocator<char> >::~__string_ref_rep #Nvariant 1() [string.cpp]
__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> >::~__string_ref() [string.cpp]
void __rwstd::__destroy<__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> > >(__type_0*) [memory:177]
void std::allocator_interface<std::allocator<char>,__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> > >::destroy(__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> >*) [memory:513]
void std::basic_string<char,std::char_traits<char>,std::allocator<char> >::__unLink() [string:915]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string() [string:297]
main [string.cpp:15]
_start [crt1.o]
* Writing 2 bytes to 0xa6d1e in the heap.
* Address 0xa6d1e is 6 bytes into a freed block at 0xa6d18 of 47 bytes.
* This block was allocated from:
malloc [rtlib.o]
c2n6Fi_Pv___1 [libCrun.so.1]
void*operator new(unsigned) [rtlib.o]
__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> >*std::basic_string<char,std::char_traits<char>,std::allocator<char> >::__getRep(unsigned,unsigned) [libCstd.so.1]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string(const char*,const std::allocator<char>&) [libCstd.so.1]
main [string.cpp:9]
_start [crt1.o]
* There have been 0 frees since this block was freed from:
free [rtlib.o]
c2k6FPv_v___1 [libCrun.so.1]
void operator delete(void*) [rtlib.o]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >&std::basic_string<char,std::char_traits<char>,std::allocator<char> >::operator=(const std::basic_string<char,std::char_traits<char>,std::allocator<char> >&) [libCstd.so.1]
main [string.cpp:13]
_start [crt1.o]

**** Purify instrumented string (pid 13888) ****
FMW: Free memory write:
* This is occurring while in:
pthread_mutex_destroy [libthread.so.1]
RWSTDMutex::~RWSTDMutex() [stdmutex.h:167]
__rwstd::__string_ref_rep<std::allocator<char> >::~__string_ref_rep #Nvariant 1() [string.cpp]
__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> >::~__string_ref() [string.cpp]
void __rwstd::__destroy<__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> > >(__type_0*) [memory:177]
void std::allocator_interface<std::allocator<char>,__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> > >::destroy(__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> >*) [memory:513]
void std::basic_string<char,std::char_traits<char>,std::allocator<char> >::__unLink() [string:915]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string() [string:297]
main [string.cpp:15]
_start [crt1.o]
* Writing 2 bytes to 0xa6d18 in the heap.
* Address 0xa6d18 is at the beginning of a freed block of 47 bytes.
* This block was allocated from:
malloc [rtlib.o]
c2n6Fi_Pv___1 [libCrun.so.1]
void*operator new(unsigned) [rtlib.o]
__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> >*std::basic_string<char,std::char_traits<char>,std::allocator<char> >::__getRep(unsigned,unsigned) [libCstd.so.1]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string(const char*,const std::allocator<char>&) [libCstd.so.1]
main [string.cpp:9]
_start [crt1.o]
* There have been 0 frees since this block was freed from:
free [rtlib.o]
c2k6FPv_v___1 [libCrun.so.1]
void operator delete(void*) [rtlib.o]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >&std::basic_string<char,std::char_traits<char>,std::allocator<char> >::operator=(const std::basic_string<char,std::char_traits<char>,std::allocator<char> >&) [libCstd.so.1]
main [string.cpp:13]
_start [crt1.o]

**** Purify instrumented string (pid 13888) ****
FMR: Free memory read:
* This is occurring while in:
unsigned std::basic_string<char,std::char_traits<char>,std::allocator<char> >::length()const [string:1346]
void std::basic_string<char,std::char_traits<char>,std::allocator<char> >::__unLink() [string:916]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string() [string:297]
main [string.cpp:15]
_start [crt1.o]
* Reading 4 bytes from 0xa6d38 in the heap.
* Address 0xa6d38 is 32 bytes into a freed block at 0xa6d18 of 47 bytes.
* This block was allocated from:
malloc [rtlib.o]
c2n6Fi_Pv___1 [libCrun.so.1]
void*operator new(unsigned) [rtlib.o]
__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> >*std::basic_string<char,std::char_traits<char>,std::allocator<char> >::__getRep(unsigned,unsigned) [libCstd.so.1]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string(const char*,const std::allocator<char>&) [libCstd.so.1]
main [string.cpp:9]
_start [crt1.o]
* There have been 0 frees since this block was freed from:
free [rtlib.o]
c2k6FPv_v___1 [libCrun.so.1]
void operator delete(void*) [rtlib.o]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >&std::basic_string<char,std::char_traits<char>,std::allocator<char> >::operator=(const std::basic_string<char,std::char_traits<char>,std::allocator<char> >&) [libCstd.so.1]
main [string.cpp:13]
_start [crt1.o]

**** Purify instrumented string (pid 13888) ****
FUM: Freeing unallocated memory:
* This is occurring while in:
free [rtlib.o]
c2k6FPv_v___1 [libCrun.so.1]
void operator delete(void*) [rtlib.o]
void std::allocator<char>::deallocate(void*,unsigned) [memory:396]
void std::allocator_interface<std::allocator<char>,char>::deallocate(char*,unsigned) [memory:493]
void std::basic_string<char,std::char_traits<char>,std::allocator<char> >::__unLink() [string:916]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string() [string:297]
main [string.cpp:15]
_start [crt1.o]
* Attempting to free block at 0xa6d18 already freed.
* This block was allocated from:
malloc [rtlib.o]
c2n6Fi_Pv___1 [libCrun.so.1]
void*operator new(unsigned) [rtlib.o]
__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> >*std::basic_string<char,std::char_traits<char>,std::allocator<char> >::__getRep(unsigned,unsigned) [libCstd.so.1]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string(const char*,const std::allocator<char>&) [libCstd.so.1]
main [string.cpp:9]
_start [crt1.o]
* There have been 1 frees since this block was freed from:
free [rtlib.o]
c2k6FPv_v___1 [libCrun.so.1]
void operator delete(void*) [rtlib.o]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >&std::basic_string<char,std::char_traits<char>,std::allocator<char> >::operator=(const std::basic_string<char,std::char_traits<char>,std::allocator<char> >&) [libCstd.so.1]
main [string.cpp:13]
_start [crt1.o]

**** Purify instrumented string (pid 13888) ****
Current file descriptors in use: 5
FIU: file descriptor 0: <stdin>
FIU: file descriptor 1: <stdout>
FIU: file descriptor 2: <stderr>
FIU: file descriptor 26: <reserved for Purify internal use>
FIU: file descriptor 27: <reserved for Purify internal use>

**** Purify instrumented string (pid 13888) ****
Purify: Searching for all memory leaks...

Memory leaked: 0 bytes (0%); potentially leaked: 0 bytes (0%)

Purify Heap Analysis (combining suppressed and unsuppressed blocks)
Blocks Bytes
Leaked 1 47
Potentially Leaked 3 107
In-Use 26 123707
----------------------------------------
Total Allocated 30 123861

**** Purify instrumented string (pid 13888) ****
Thread Summary : 1 threads in existence
* Thread 0 [main thread]
Stack Limit : (0xff3f0000 0xffbf0000), size = 0x800000

**** Purify instrumented string (pid 13888) ****
* Program exited with status code 0.
* 6 access errors, 6 total occurrences.
* 0 bytes leaked.
* 0 bytes potentially leaked.
* Basic memory usage (including Purify overhead):
331996 code
92532 data/bss
131072 heap (peak use)
1856 stack
* Shared library memory usage (including Purify overhead):
1456 libpure_solaris2_init.so.1 (shared code)
252 libpure_solaris2_init.so.1 (private data)
2255839 libCstd.so.1_pure_p3_c0_105022037_58_32_3592668S (shared code)
28588 libCstd.so.1_pure_p3_c0_105022037_58_32_3592668S (private data)
54269 libCrun.so.1_pure_p3_c0_105022037_58_32_1244656S (shared code)
24688 libCrun.so.1_pure_p3_c0_105022037_58_32_1244656S (private data)
139048 libm.so.1_pure_p3_c0_105022037_58_32_1289524S (shared code)
1224 libm.so.1_pure_p3_c0_105022037_58_32_1289524S (private data)
3968 libw.so.1_pure_p3_c0_105022037_58_32_1187000S (shared code)
0 libw.so.1_pure_p3_c0_105022037_58_32_1187000S (private data)
132888 libthread.so.1_pure_p3_c0_105022037_58_32_1408248S (shared code)
26192 libthread.so.1_pure_p3_c0_105022037_58_32_1408248S (private data)
1105144 libc.so.1_pure_p3_c0_105022037_58_32_1180272S (shared code)
111036 libc.so.1_pure_p3_c0_105022037_58_32_1180272S (private data)
2404 libdl.so.1_pure_p3_c0_105022037_58_32_5292S (shared code)
4 libdl.so.1_pure_p3_c0_105022037_58_32_5292S (private data)
13192 libinternal_stubs.so.1 (shared code)
932 libinternal_stubs.so.1 (private data)
31866 librt.so.1_pure_p3_c0_105022037_58_32_1269024S (shared code)
2044 librt.so.1_pure_p3_c0_105022037_58_32_1269024S (private data)
44541 libaio.so.1_pure_p3_c0_105022037_58_32_1227208S (shared code)
6104 libaio.so.1_pure_p3_c0_105022037_58_32_1227208S (private data)
14112 libc_psr.so.1_pure_p3_c0_105022037_58_32 (shared code)
0 libc_psr.so.1_pure_p3_c0_105022037_58_32 (private data)

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 13 2003
Added on Feb 18 2003
3 comments
248 views