From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8565 invoked by alias); 12 Aug 2004 19:57:01 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 8547 invoked by uid 48); 12 Aug 2004 19:56:58 -0000 Date: Thu, 12 Aug 2004 19:57:00 -0000 From: "debrak at sgi dot com" To: gcc-bugs@gcc.gnu.org Message-ID: <20040812195652.17012.debrak@sgi.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/17012] New: std::list's function, remove, looks like it is reading memory that has been freed. X-Bugzilla-Reason: CC X-SW-Source: 2004-08/txt/msg01172.txt.bz2 List-Id: --------------------------------------------------------- I use purify to look for errors in my code. But I think it may have found a "Free Memory Read" error in the std::list template's function, remove. My program is: ---------------------------- #include #include using namespace std; int main() { list var; var.push_back(0); var.push_back(1); var.push_back(2); var.push_back(3); var.push_back(4); cout<<"BEFORE remove():"<::iterator i = var.begin(); i!=var.end(); i++) { cout<<"*i="<<*i<::iterator i0 = var.begin(); i0++; i0++; var.remove(*i0); cout<<"\nAFTER remove():"<::iterator i = var.begin(); i!=var.end(); i++) { cout<<"*i="<<*i<::_M_initialize_ctype( void) [ctype_members.cc:265] std::ctype< wchar_t>::ctype( unsigned) [ctype.cc:91] std::locale::_Impl::_Impl( unsigned) [new:92] std::locale::_S_initialize_once( void) [new:92] std::locale::_S_initialize( void) [locale_init.cc:155] std::locale::locale( void) [locale_init.cc:103] std::ios_base::Init::Init( void) [streambuf:437] __static_initialization_and_destruction_0( int, int) [iostream:77] _GLOBAL__I_main [bug1.cpp:8] __do_global_ctors_aux [crtend.o] _init [crti.o] __libc_start_main [libc.so.6] _start [crt1.o] * Reading 4 bytes from 0xbfffedd8 on the stack. * Address 0xbfffedd8 is 96 bytes below frame pointer in function wctob. **** Purify instrumented bug1.pure (pid 3776) **** UMR: Uninitialized memory read: * This is occurring while in: __gconv_transform_ascii_internal [libc.so.6] btowc [libc.so.6] std::ctype< wchar_t>::_M_initialize_ctype( void) [ctype_members.cc:277] std::ctype< wchar_t>::ctype( unsigned) [ctype.cc:91] std::locale::_Impl::_Impl( unsigned) [new:92] std::locale::_S_initialize_once( void) [new:92] std::locale::_S_initialize( void) [locale_init.cc:155] std::locale::locale( void) [locale_init.cc:103] std::ios_base::Init::Init( void) [streambuf:437] __static_initialization_and_destruction_0( int, int) [iostream:77] _GLOBAL__I_main [bug1.cpp:8] __do_global_ctors_aux [crtend.o] _init [crti.o] __libc_start_main [libc.so.6] _start [crt1.o] * Reading 4 bytes from 0xbfffede4 on the stack. * Address 0xbfffede4 is 84 bytes below frame pointer in function btowc. **** Purify instrumented bug1.pure (pid 3776) **** UMR: Uninitialized memory read: * This is occurring while in: __gconv_transform_ascii_internal [libc.so.6] btowc [libc.so.6] std::numpunct< wchar_t>::_M_initialize_numpunct(__locale_struct *) [numeric_members.cc:119] std::locale::_Impl::_Impl( unsigned) [locale_facets.h:1700] std::locale::_S_initialize_once( void) [new:92] std::locale::_S_initialize( void) [locale_init.cc:155] std::locale::locale( void) [locale_init.cc:103] std::ios_base::Init::Init( void) [streambuf:437] __static_initialization_and_destruction_0( int, int) [iostream:77] _GLOBAL__I_main [bug1.cpp:8] __do_global_ctors_aux [crtend.o] _init [crti.o] __libc_start_main [libc.so.6] _start [crt1.o] * Reading 4 bytes from 0xbfffee04 on the stack. * Address 0xbfffee04 is 84 bytes below frame pointer in function btowc. **** Purify instrumented bug1.pure (pid 3776) **** UMR: Uninitialized memory read: * This is occurring while in: __gconv_transform_ascii_internal [libc.so.6] btowc [libc.so.6] std::numpunct< wchar_t>::_M_initialize_numpunct(__locale_struct *) [numeric_members.cc:125] std::locale::_Impl::_Impl( unsigned) [locale_facets.h:1700] std::locale::_S_initialize_once( void) [new:92] std::locale::_S_initialize( void) [locale_init.cc:155] std::locale::locale( void) [locale_init.cc:103] std::ios_base::Init::Init( void) [streambuf:437] __static_initialization_and_destruction_0( int, int) [iostream:77] _GLOBAL__I_main [bug1.cpp:8] __do_global_ctors_aux [crtend.o] _init [crti.o] __libc_start_main [libc.so.6] _start [crt1.o] * Reading 4 bytes from 0xbfffee04 on the stack. * Address 0xbfffee04 is 84 bytes below frame pointer in function btowc. **** Purify instrumented bug1.pure (pid 3776) **** UMR: Uninitialized memory read: * This is occurring while in: __gconv_transform_ascii_internal [libc.so.6] btowc [libc.so.6] std::moneypunct< wchar_t,false>::_M_initialize_moneypunct(__locale_struct *, char const *) [monetary_members.cc:524] std::locale::_Impl::_Impl( unsigned) [locale_facets.h:3581] std::locale::_S_initialize_once( void) [new:92] std::locale::_S_initialize( void) [locale_init.cc:155] std::locale::locale( void) [locale_init.cc:103] std::ios_base::Init::Init( void) [streambuf:437] __static_initialization_and_destruction_0( int, int) [iostream:77] _GLOBAL__I_main [bug1.cpp:8] __do_global_ctors_aux [crtend.o] _init [crti.o] __libc_start_main [libc.so.6] _start [crt1.o] * Reading 4 bytes from 0xbfffedc4 on the stack. * Address 0xbfffedc4 is 84 bytes below frame pointer in function btowc. **** Purify instrumented bug1.pure (pid 3776) **** UMR: Uninitialized memory read: * This is occurring while in: __gconv_transform_ascii_internal [libc.so.6] btowc [libc.so.6] std::moneypunct< wchar_t,true>::_M_initialize_moneypunct(__locale_struct *, char const *) [monetary_members.cc:379] std::locale::_Impl::_Impl( unsigned) [locale_facets.h:3581] std::locale::_S_initialize_once( void) [new:92] std::locale::_S_initialize( void) [locale_init.cc:155] std::locale::locale( void) [locale_init.cc:103] std::ios_base::Init::Init( void) [streambuf:437] __static_initialization_and_destruction_0( int, int) [iostream:77] _GLOBAL__I_main [bug1.cpp:8] __do_global_ctors_aux [crtend.o] _init [crti.o] __libc_start_main [libc.so.6] _start [crt1.o] * Reading 4 bytes from 0xbfffedc4 on the stack. * Address 0xbfffedc4 is 84 bytes below frame pointer in function btowc. **** Purify instrumented bug1.pure (pid 3776) **** FMR: Free memory read: * This is occurring while in: std::list< int,std::allocator< int>>::remove( int const &) [list.tcc:181] main [bug1.cpp:22] __libc_start_main [libc.so.6] _start [crt1.o] * Reading 4 bytes from 0x80a62e8 in the heap. * Address 0x80a62e8 is 8 bytes into a freed block at 0x80a62e0 of 12 bytes. * This block was allocated from: malloc [rtlib.o] operator new( unsigned) [new_op.cc:48] __gnu_cxx::new_allocator>::allocate( unsigned, void const *) [new_allocator.h:81] std::_List_base< int,std::allocator< int>>::_M_get_node( void) [stl_list.h:309] std::list< int,std::allocator< int>>::_M_create_node( int const &) [stl_list.h:433] std::list< int,std::allocator< int>>::_M_insert(std::_List_iterator< int>, int const &) [stl_list.h:1161] std::list< int,std::allocator< int>>::push_back( int const &) [stl_list.h:783] main [bug1.cpp:10] __libc_start_main [libc.so.6] _start [crt1.o] * There have been 0 frees since this block was freed from: free [rtlib.o] _ZdLpV [del_op.cc:40] __gnu_cxx::new_allocator>::deallocate(std::_List_node< int> *, unsigned) [new_allocator.h:86] std::_List_base< int,std::allocator< int>>::_M_put_node(std::_List_node< int> *) [stl_list.h:313] std::list< int,std::allocator< int>>::_M_erase(std::_List_iterator< int>) [stl_list.h:1172] std::list< int,std::allocator< int>>::remove( int const &) [list.tcc:182] main [bug1.cpp:22] __libc_start_main [libc.so.6] _start [crt1.o] **** Purify instrumented bug1.pure (pid 3776) **** Current file descriptors in use: 5 FIU: file descriptor 0: FIU: file descriptor 1: FIU: file descriptor 2: FIU: file descriptor 26: FIU: file descriptor 27: **** Purify instrumented bug1.pure (pid 3776) **** 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 16 Potentially Leaked 0 0 In-Use 1 64 ---------------------------------------- Total Allocated 2 80 **** Purify instrumented bug1.pure (pid 3776) **** * Program exited with status code 0. * 7 access errors, 470 total occurrences. * 0 bytes leaked. * 0 bytes potentially leaked. * Basic memory usage (including Purify overhead): 236244 code 144532 data/bss 4236 heap (peak use) 4184 stack * Shared library memory usage (including Purify overhead): 1782596 libstdc++.so.6_pure_p3_c0_108272013_2418-187xsmp_32 (shared code) 125556 libstdc++.so.6_pure_p3_c0_108272013_2418-187xsmp_32 (private data) 300483 libm.so.6_pure_p3_c0_108272013_2418-187xsmp_32 (shared code) 724 libm.so.6_pure_p3_c0_108272013_2418-187xsmp_32 (private data) 73956 libgcc_s.so.1_pure_p3_c0_108272013_2418-187xsmp_32 (shared code) 2280 libgcc_s.so.1_pure_p3_c0_108272013_2418-187xsmp_32 (private data) 18023 libdl.so.2_pure_p3_c0_108272013_2418-187xsmp_32 (shared code) 648 libdl.so.2_pure_p3_c0_108272013_2418-187xsmp_32 (private data) 8097 libinternal_stubs.so.1.0 (shared code) 372 libinternal_stubs.so.1.0 (private data) 2951235 libc.so.6_pure_p3_c0_108272013_2418-187xsmp_32 (shared code) 36448 libc.so.6_pure_p3_c0_108272013_2418-187xsmp_32 (private data) 77321 ld-linux.so.2 (shared code) 1744 ld-linux.so.2 (private data) -- Summary: std::list's function, remove, looks like it is reading memory that has been freed. Product: gcc Version: 3.4.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: debrak at sgi dot com CC: debrak at sgi dot com,gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17012