delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/06/01/10:08:31

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Andris Pavenis <pavenis AT latnet DOT lv>
To: djgpp AT delorie DOT com
Subject: Re: "delete" crash
Date: Tue, 1 Jun 2004 16:40:02 +0300
User-Agent: KMail/1.6.2
References: <a716df2e DOT 0406010443 DOT 581cf241 AT posting DOT google DOT com>
In-Reply-To: <a716df2e.0406010443.581cf241@posting.google.com>
Cc: tonytg13 AT yahoo DOT com (tony ganchev)
MIME-Version: 1.0
Message-Id: <200406011640.02915.pavenis@latnet.lv>
Reply-To: djgpp AT delorie DOT com

On Tuesday 01 June 2004 15:43, Tony Ganchev wrote:
> Guys, I have the following problem:
> I have written a class, implementing dynamic linked list with
> elements, containing strings. Unfortunately when I use the Remove
> method of the GStringList class, my program crashes. I use DJGPP under
> WinXP. I suppose the problem is some sort of segmentation although
> there is nothing like SIGSEGV signal, the program just stops
> execution. I have made sure that all of the elements are created using
> "new". If anyone is eager to help me, here is the source
>

... source removed ...

At first some notes: 

1) putting all stuff in a single source file would make testing simpler
2) DJGPP conio.h stuff is not related to the problem, so it's
    best to remove it.
3) Long comment lines gets split in e-mail client, as the result 
    more time is needed than it should be. 

Compiled for Linux. valgrind-2.1.1 output included. It should 
give some hints for bugs. I don't want to mess with it more
myself.

Andris

==14758== Memcheck, a memory error detector for x86-linux.
==14758== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward.
==14758== Using valgrind-2.1.1, a program supervision framework for x86-linux.
==14758== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward.
==14758== For more details, rerun with: -v
==14758== 
==14758== Invalid free() / delete / delete[]
==14758==    at 0x3C01DAC9: operator delete[](void*) (vg_replace_malloc.c:131)
==14758==    by 0x8048686: GString::Empty() (__string.h:71)
==14758==    by 0x804869D: GString::operator=(char const*) (__string.h:86)
==14758==    by 0x8049028: main (main.cc:18)
==14758==  Address 0x3C251024 is 0 bytes inside a block of size 6 free'd
==14758==    at 0x3C01DAC9: operator delete[](void*) (vg_replace_malloc.c:131)
==14758==    by 0x8048686: GString::Empty() (__string.h:71)
==14758==    by 0x8049210: GString::~GString() (__string.h:28)
==14758==    by 0x8048CBF: GStringList::Add(GString const&) (__slist.h:135)
==14758==    by 0x8049014: main (main.cc:17)
==14758== 
==14758== Invalid free() / delete / delete[]
==14758==    at 0x3C01DAC9: operator delete[](void*) (vg_replace_malloc.c:131)
==14758==    by 0x8048686: GString::Empty() (__string.h:71)
==14758==    by 0x804869D: GString::operator=(char const*) (__string.h:86)
==14758==    by 0x8049051: main (main.cc:20)
==14758==  Address 0x3C2510CC is 0 bytes inside a block of size 6 free'd
==14758==    at 0x3C01DAC9: operator delete[](void*) (vg_replace_malloc.c:131)
==14758==    by 0x8048686: GString::Empty() (__string.h:71)
==14758==    by 0x8049210: GString::~GString() (__string.h:28)
==14758==    by 0x8048DB3: GStringList::Insert(GString const&, unsigned long) (__slist.h:159)
==14758==    by 0x804903D: main (main.cc:19)
==14758== 
==14758== Invalid free() / delete / delete[]
==14758==    at 0x3C01DAC9: operator delete[](void*) (vg_replace_malloc.c:131)
==14758==    by 0x8048686: GString::Empty() (__string.h:71)
==14758==    by 0x804869D: GString::operator=(char const*) (__string.h:86)
==14758==    by 0x804907A: main (main.cc:22)
==14758==  Address 0x3C251174 is 0 bytes inside a block of size 6 free'd
==14758==    at 0x3C01DAC9: operator delete[](void*) (vg_replace_malloc.c:131)
==14758==    by 0x8048686: GString::Empty() (__string.h:71)
==14758==    by 0x8049210: GString::~GString() (__string.h:28)
==14758==    by 0x8048DB3: GStringList::Insert(GString const&, unsigned long) (__slist.h:159)
==14758==    by 0x8049066: main (main.cc:21)
==14758== 
==14758== Invalid free() / delete / delete[]
==14758==    at 0x3C01DAC9: operator delete[](void*) (vg_replace_malloc.c:131)
==14758==    by 0x8048686: GString::Empty() (__string.h:71)
==14758==    by 0x804869D: GString::operator=(char const*) (__string.h:86)
==14758==    by 0x80490A3: main (main.cc:24)
==14758==  Address 0x3C25121C is 0 bytes inside a block of size 6 free'd
==14758==    at 0x3C01DAC9: operator delete[](void*) (vg_replace_malloc.c:131)
==14758==    by 0x8048686: GString::Empty() (__string.h:71)
==14758==    by 0x8049210: GString::~GString() (__string.h:28)
==14758==    by 0x8048DB3: GStringList::Insert(GString const&, unsigned long) (__slist.h:159)
==14758==    by 0x804908F: main (main.cc:23)
==14758== 
==14758== Invalid free() / delete / delete[]
==14758==    at 0x3C01DAC9: operator delete[](void*) (vg_replace_malloc.c:131)
==14758==    by 0x8048686: GString::Empty() (__string.h:71)
==14758==    by 0x8049210: GString::~GString() (__string.h:28)
==14758==    by 0x8049190: main (main.cc:33)
==14758==  Address 0x3C2512C4 is 0 bytes inside a block of size 6 free'd
==14758==    at 0x3C01DAC9: operator delete[](void*) (vg_replace_malloc.c:131)
==14758==    by 0x8048686: GString::Empty() (__string.h:71)
==14758==    by 0x8049210: GString::~GString() (__string.h:28)
==14758==    by 0x8048DB3: GStringList::Insert(GString const&, unsigned long) (__slist.h:159)
==14758==    by 0x80490B8: main (main.cc:25)
Requested 1
Requested 0
Requested 2
Requested 1
Requested 3
Requested 2
------
......
;;;;;;
//////
Requested 0
0: Line3
Requested 1
1: Line4
Requested 2
2: Line5
Requested 3
3: Line1
==14758== 
==14758== ERROR SUMMARY: 5 errors from 5 contexts (suppressed: 17 from 1)
==14758== malloc/free: in use at exit: 56 bytes in 8 blocks.
==14758== malloc/free: 15 allocs, 12 frees, 100 bytes allocated.
==14758== For a detailed leak analysis,  rerun with: --leak-check=yes
==14758== For counts of detected errors, rerun with: -v


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019