From MAILER-DAEMON Tue Feb 01 09:52:41 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1CvzOT-0000p2-CX
	for mharc-bug-commoncpp@gnu.org; Tue, 01 Feb 2005 09:52:41 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1CvcJy-0004Xq-6t
	for bug-commoncpp@gnu.org; Mon, 31 Jan 2005 09:14:30 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1CvcJv-0004Wo-9w
	for bug-commoncpp@gnu.org; Mon, 31 Jan 2005 09:14:28 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1CvcJv-0004RW-2Q
	for bug-commoncpp@gnu.org; Mon, 31 Jan 2005 09:14:27 -0500
Received: from [62.169.194.3] (helo=fesscrpp2.tellas.gr)
	by monty-python.gnu.org with esmtp (Exim 4.34) id 1Cvc7E-0007rH-WB
	for bug-commoncpp@gnu.org; Mon, 31 Jan 2005 09:01:25 -0500
Received: from mail.htr.gr (62.169.204.147) by fesscrpp2.tellas.gr (7.0.028)
	id 41C1CDEE001308A1 for bug-commoncpp@gnu.org;
	Mon, 31 Jan 2005 16:00:42 +0200
Received: (qmail 26774 invoked by uid 514); 31 Jan 2005 14:20:47 -0000
Received: from linux@vmpsoft.com by gw by uid 510 with qmail-scanner-1.21st 
	(clamdscan: 0.70-rc. spamassassin: 2.63.  Clear:RC:1(192.168.0.20):. 
	Processed in 0.040658 secs); 31 Jan 2005 14:20:47 -0000
Received: from vmstation.htrlan.gr (HELO ?192.168.0.20?) (192.168.0.20)
	by mail.htr.gr with SMTP; 31 Jan 2005 14:20:47 -0000
Message-ID: <41FE3A17.9040909@vmpsoft.com>
Date: Mon, 31 Jan 2005 16:00:55 +0200
From: John Chronakis <linux@vmpsoft.com>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: bug-commoncpp@gnu.org
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Mailman-Approved-At: Tue, 01 Feb 2005 09:52:39 -0500
Subject: help
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 31 Jan 2005 14:14:31 -0000





From MAILER-DAEMON Wed Feb 02 12:43:05 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1CwOWv-0002at-OF
	for mharc-bug-commoncpp@gnu.org; Wed, 02 Feb 2005 12:43:05 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1CwOGf-00075X-Mc
	for bug-commoncpp@gnu.org; Wed, 02 Feb 2005 12:26:18 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1CwOGT-0006yU-1d
	for bug-commoncpp@gnu.org; Wed, 02 Feb 2005 12:26:09 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1CwOGS-0006vk-Mm
	for bug-commoncpp@gnu.org; Wed, 02 Feb 2005 12:26:04 -0500
Received: from [193.52.61.53] (helo=messager.iut-bm.univ-fcomte.fr)
	by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168)
	(Exim 4.34) id 1CwNxn-0004E6-1v
	for bug-commoncpp@gnu.org; Wed, 02 Feb 2005 12:06:47 -0500
Received: from [193.52.61.134] (sdomas@prodigy.iut-bm.univ-fcomte.fr
	[193.52.61.134])
	by messager.iut-bm.univ-fcomte.fr (8.13.2/8.13.2/Debian-1) with ESMTP
	id j12H6a5V029257
	for <bug-commoncpp@gnu.org>; Wed, 2 Feb 2005 18:06:37 +0100
Message-ID: <4201089C.5020406@iut-bm.univ-fcomte.fr>
Date: Wed, 02 Feb 2005 18:06:36 +0100
From: "Stephane Domas,,," <stephane.domas@iut-bm.univ-fcomte.fr>
Organization: LIFC
User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr;
	rv:1.7.5) Gecko/20050105 Debian/1.7.5-1
X-Accept-Language: fr, en-us
MIME-Version: 1.0
To: bug-commoncpp@gnu.org
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Scanned-By: MIMEDefang 2.48 on 193.52.61.53
X-Mailman-Approved-At: Wed, 02 Feb 2005 12:43:04 -0500
Subject: pb : semaphore crashing with kernel 2..4.x
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 02 Feb 2005 17:26:23 -0000

hello

I'm writing you to ask if you already seen problems with semaphore and 
thread termination under kernel 2.4.X.
To describe more precisely my problem :

I launch a process, which instanciate 7 semaphores, agregate in a 
Handler object. Then the process  launches 3 threads (let's call them S, 
R, and C). These three threads own the Handler object, so they can post 
and/or wait on these semaphore. 3 first semaphore are used by the 
process to wake up S,R,C and the three others are used by S, R and C to 
signal to the process that they are stopped.

Further in the execution, the process launches a new thread (let's call 
it T) that also owns the handler object. And for an obscur reason, when 
this thread or another one do a post on the the 7th semaphore, it 
crashes. Very surprisingly, this crash does not occur on a 2.6.X kernel.

Another bug [ if I do not post on the 7th semaphore ] : if I let the 
last thread T ends himself, it calls the final method which only 
contains a message print. This works well. But ... if the thread do a 
long sleep [ just before the end of run() ], and the process tries to 
delete it (calling terminate in the destructor of T), the thread prints 
out the message and then blocks infinitely. Thus, ending itself works 
but forcing a thread to terminate does not work. Once again, this bug 
disappear when using a 2.6.8 kernel !

Have you any idea on why this behaviour ??

Thanx
S. Domas

-- 
   __________ _______________ ____________________ ________ ______ ___
  //         /   _           /                    /        /      /---\
 //___  _/_     /_|   ___/_  _____   ______/_  ____ __       ____//   |
 ||     |      //          ____           |                      ||   /
 ||       ooo //ooo       |----|                                 ||  /
 ||     OOOOOOOOOOOO    __|____|__  "Leave yourself behind..."   ||--
 ||    OOO  OOOOOOOOO     / Q o\                                 ||
 ||    OO  OOOOOO_OOO    (___~~_)      but never forget ur hat   ||
 ||    OOO OOOOO|_\OO   /=/  \\                                  ||
 ||     OOO OOOOO\_\___/=/    |          - Hervald's saying -    ||
 ||      OOOOOOOOO\/|_|\/     /\                                 ||
 ||___ _  OOOOOOO       ____         ___ __      __|___    ___ __||
 //   /                    /           /           /             //
//_____/-____________/-_______/--___________/__________/--______//







From MAILER-DAEMON Wed Feb 02 12:54:39 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1CwOi7-0004c7-OU
	for mharc-bug-commoncpp@gnu.org; Wed, 02 Feb 2005 12:54:39 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1CwOhJ-0004US-UM
	for bug-commoncpp@gnu.org; Wed, 02 Feb 2005 12:53:51 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1CwOhC-0004Op-2S
	for bug-commoncpp@gnu.org; Wed, 02 Feb 2005 12:53:45 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1CwOhB-0004KN-4u
	for bug-commoncpp@gnu.org; Wed, 02 Feb 2005 12:53:41 -0500
Received: from [216.218.222.122] (helo=mail.ostel.com)
	by monty-python.gnu.org with esmtp (Exim 4.34) id 1CwONR-000739-2I
	for bug-commoncpp@gnu.org; Wed, 02 Feb 2005 12:33:17 -0500
Received: from [192.168.10.115] (static-138-89-254-170.atc.east.verizon.net
	[138.89.254.170])
	by mail.ostel.com (Postfix) with ESMTP id 73C2A2F2874;
	Wed,  2 Feb 2005 09:55:43 -0800 (PST)
Message-ID: <42010ED9.2080707@ostel.com>
Date: Wed, 02 Feb 2005 12:33:13 -0500
From: David Sugar <dyfet@ostel.com>
Organization: GNU Project
User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: "Stephane Domas,,," <stephane.domas@iut-bm.univ-fcomte.fr>
References: <4201089C.5020406@iut-bm.univ-fcomte.fr>
In-Reply-To: <4201089C.5020406@iut-bm.univ-fcomte.fr>
Content-Type: multipart/mixed; boundary="------------040108050409030306070802"
Cc: bug-commoncpp@gnu.org
Subject: Re: pb : semaphore crashing with kernel 2..4.x
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 02 Feb 2005 17:54:38 -0000

This is a multi-part message in MIME format.
--------------040108050409030306070802
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

We recently changed the implimentation from using semaphores to using a 
construct built from a conditional, as it was far more portable and 
allowed for timeouts on wait.  I do recall hearing that some specific 
versions of glibc have broken implimentations of conditionals, however. 
  Is this a machine built with debian woody and the glibc version it uses?
Which version of Common C++ are you using?

Stephane Domas,,, wrote:
> hello
> 
> I'm writing you to ask if you already seen problems with semaphore and 
> thread termination under kernel 2.4.X.
> To describe more precisely my problem :
> 
> I launch a process, which instanciate 7 semaphores, agregate in a 
> Handler object. Then the process  launches 3 threads (let's call them S, 
> R, and C). These three threads own the Handler object, so they can post 
> and/or wait on these semaphore. 3 first semaphore are used by the 
> process to wake up S,R,C and the three others are used by S, R and C to 
> signal to the process that they are stopped.
> 
> Further in the execution, the process launches a new thread (let's call 
> it T) that also owns the handler object. And for an obscur reason, when 
> this thread or another one do a post on the the 7th semaphore, it 
> crashes. Very surprisingly, this crash does not occur on a 2.6.X kernel.
> 
> Another bug [ if I do not post on the 7th semaphore ] : if I let the 
> last thread T ends himself, it calls the final method which only 
> contains a message print. This works well. But ... if the thread do a 
> long sleep [ just before the end of run() ], and the process tries to 
> delete it (calling terminate in the destructor of T), the thread prints 
> out the message and then blocks infinitely. Thus, ending itself works 
> but forcing a thread to terminate does not work. Once again, this bug 
> disappear when using a 2.6.8 kernel !
> 
> Have you any idea on why this behaviour ??
> 
> Thanx
> S. Domas
> 

--------------040108050409030306070802
Content-Type: text/x-vcard; charset=utf-8;
 name="dyfet.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="dyfet.vcf"

begin:vcard
fn:David Sugar
n:Sugar;David
org:GNU Project
adr:;;23 Olin Drive;Cape May Court House;NJ;08210;USA
email;internet:dyfet@ostel.com
tel;home:1 609 465 5336
tel;cell:1 908 917 6084
x-mozilla-html:FALSE
url:http://www.ostel.com
version:2.1
end:vcard


--------------040108050409030306070802--



From MAILER-DAEMON Thu Feb 10 05:27:38 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1CzBXr-0004H8-Mx
	for mharc-bug-commoncpp@gnu.org; Thu, 10 Feb 2005 05:27:36 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1CzBXZ-0004El-2k
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 05:27:20 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1CzBXP-0004D2-6e
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 05:27:12 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1CzBXN-00042a-3l
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 05:27:05 -0500
Received: from [206.190.39.191] (helo=web53001.mail.yahoo.com)
	by monty-python.gnu.org with smtp (Exim 4.34) id 1CzBKE-0007Tp-Pk
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 05:13:31 -0500
Received: (qmail 96849 invoked by uid 60001); 10 Feb 2005 10:13:29 -0000
Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com;
	b=bev4FW7onyyhzgGVjjuTnV435GNkx8z0SuzOvKwka950Q3cmImcYPcxsDS+fFqFNZL55FdqYowA11E1j5LrUNm7yuugJLTCaJkWR2tk+g0QHBm8ETV3oa88J2WXu0MUPdbD1fGjnv6k6dWl5LHL/olqXi/za7tOSNGxIhDr2EGI=
	; 
Message-ID: <20050210101329.96847.qmail@web53001.mail.yahoo.com>
Received: from [153.1.60.204] by web53001.mail.yahoo.com via HTTP;
	Thu, 10 Feb 2005 02:13:29 PST
Date: Thu, 10 Feb 2005 02:13:29 -0800 (PST)
From: Rami Saarinen <rs55862@yahoo.com>
To: bug-commoncpp@gnu.org
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Subject: Haunting free(): invalid pointer 0x8a11604! 
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 10 Feb 2005 10:27:32 -0000

Hello again, 

Ia currently doing some restructuring on the program that I had probelms
with few moths ago. I just poke my editor into some very nasty stuff and
I'd like to ask if any of you have any idea why I do get a buch of Invalid
pointer error messages. 

The program is heavily threaded "MessageDispatch" style of client/server
program. The proble is in the server. The server also uses xerces-c++ and
sqlite3. 

I just updated common c++ form 1.0.9 to 1.3.1. None of the threads have
final() method defined and the threads are detached() and *not* started().

The invalid pointer error does not appear on 1.0.9 version. 

I have been using valgrind (altought it's pthread support is incomplete)
to find another proble that will crash the program when it tries to create
XercesDOMParser. I think these problems *may* be interlinked as the crash
occurs in malloc() -> so maybe the TCPSession + other thread stuff messes
the memory so that malloc fails.

Anyway when the  free(): invalid pointer 0xxxxxxxxx! appears Valgrind will
display quite many of Invalid read messages like: 

==3015== Invalid read of size 4
==3015==    at 0x1BD0E831: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==3015==    by 0x1BD0FA0E:
ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==3015==    by 0x1BD0E90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
==3015==    by 0x1BCCD847: thread_wrapper (vg_libpthread.c:867)
==3015==  Address 0x1BF65B98 is 240 bytes inside a block of size 416
free'd
==3015==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==3015==    by 0x8057F87:
TCPSessionThread<AgentContainer*>::~TCPSessionThread()
(AgentContainer.cpp:125)
==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
==3015==    by 0x1BD0E804: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.0.1)


and invalid write messages like: 

==3015== Thread 4:
==3015== Invalid write of size 4
==3015==    at 0x1BD0E2EB: ost::Thread::~Thread() (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==3015==    by 0x1BD0E82E: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==3015==    by 0x1BD0FA0E:
ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==3015==    by 0x1BD0E90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
==3015==  Address 0x1BF65B34 is 140 bytes inside a block of size 416
free'd
==3015==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==3015==    by 0x8057F87:
TCPSessionThread<AgentContainer*>::~TCPSessionThread()
(AgentContainer.cpp:125)
==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
==3015==    by 0x1BD0E804: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==3015==


But the most interesting bit is: 

==3015== Thread 4:
==3015== Invalid free() / delete / delete[]
==3015==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==3015==    by 0x1BD0E320: ost::Thread::~Thread() (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==3015==    by 0x1BD0E82E: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==3015==    by 0x1BD0FA0E:
ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==3015==  Address 0x1BF65B34 is 140 bytes inside a block of size 416
free'd
==3015==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==3015==    by 0x8057F87:
TCPSessionThread<AgentContainer*>::~TCPSessionThread()
(AgentContainer.cpp:125)
==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
==3015==    by 0x1BD0E804: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==3015==


I am not reserving or freeing any memory (well I do create a new srting
that will be deleted elsewhere). Any Ideas? Am I just doing All Things
Wrong? Should I consider a career change? 

I'll provide any additional information you need. 

Thanks again!

--
Rami Saarinen

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



From MAILER-DAEMON Thu Feb 10 08:04:14 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1CzDsF-0007xQ-Da
	for mharc-bug-commoncpp@gnu.org; Thu, 10 Feb 2005 07:56:47 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1CzDrz-0007ow-1F
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 07:56:33 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1CzDrp-0007k8-Bl
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 07:56:22 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1CzDrp-0007jJ-5m
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 07:56:21 -0500
Received: from [216.218.222.122] (helo=mail.ostel.com)
	by monty-python.gnu.org with esmtp (Exim 4.34) id 1CzDZw-0004Ow-E2
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 07:37:52 -0500
Received: from [192.168.1.101] (pool-138-89-240-2.atc.east.verizon.net
	[138.89.240.2])
	by mail.ostel.com (Postfix) with ESMTP id 8C6402F2873;
	Thu, 10 Feb 2005 05:01:20 -0800 (PST)
Message-ID: <420B559C.40404@ostel.com>
Date: Thu, 10 Feb 2005 07:37:48 -0500
From: David Sugar <dyfet@ostel.com>
Organization: GNU Project
User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Rami Saarinen <rs55862@yahoo.com>
References: <20050210101329.96847.qmail@web53001.mail.yahoo.com>
In-Reply-To: <20050210101329.96847.qmail@web53001.mail.yahoo.com>
Content-Type: multipart/mixed; boundary="------------080105010402030505040309"
Cc: bug-commoncpp@gnu.org
Subject: Re: Haunting free(): invalid pointer 0x8a11604!
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 10 Feb 2005 12:56:39 -0000

This is a multi-part message in MIME format.
--------------080105010402030505040309
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hmm...perhaps it is a dynamic casting issue.  The thread close method 
itself is only really aware of a "Thread" object as the base class 
itself, at that point in time.  If it is unable to handle the delete of 
the derived virtual object by recasting the pointer references, then 
perhaps the order of base classes listed in the final derived class can 
be changed, so that TCPSession() is the first base in your derived 
class.  In fact, I would also consider reversing the order of 
declaration of TCPSession in cc++/socket.h, so that public Thread 
appears before public TCPStream for the same reason.

I have never noticed this problem in normal (non-detached) threads, 
since the "delete" is always invoked against the derived class, and not 
a virtual base.

Rami Saarinen wrote:
> Hello again, 
> 
> Ia currently doing some restructuring on the program that I had probelms
> with few moths ago. I just poke my editor into some very nasty stuff and
> I'd like to ask if any of you have any idea why I do get a buch of Invalid
> pointer error messages. 
> 
> The program is heavily threaded "MessageDispatch" style of client/server
> program. The proble is in the server. The server also uses xerces-c++ and
> sqlite3. 
> 
> I just updated common c++ form 1.0.9 to 1.3.1. None of the threads have
> final() method defined and the threads are detached() and *not* started().
> 
> The invalid pointer error does not appear on 1.0.9 version. 
> 
> I have been using valgrind (altought it's pthread support is incomplete)
> to find another proble that will crash the program when it tries to create
> XercesDOMParser. I think these problems *may* be interlinked as the crash
> occurs in malloc() -> so maybe the TCPSession + other thread stuff messes
> the memory so that malloc fails.
> 
> Anyway when the  free(): invalid pointer 0xxxxxxxxx! appears Valgrind will
> display quite many of Invalid read messages like: 
> 
> ==3015== Invalid read of size 4
> ==3015==    at 0x1BD0E831: ost::Thread::close() (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==    by 0x1BD0FA0E:
> ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==    by 0x1BD0E90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==    by 0x1BCCD847: thread_wrapper (vg_libpthread.c:867)
> ==3015==  Address 0x1BF65B98 is 240 bytes inside a block of size 416
> free'd
> ==3015==    at 0x1B90313F: operator delete(void*)
> (vg_replace_malloc.c:156)
> ==3015==    by 0x8057F87:
> TCPSessionThread<AgentContainer*>::~TCPSessionThread()
> (AgentContainer.cpp:125)
> ==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
> ==3015==    by 0x1BD0E804: ost::Thread::close() (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> 
> 
> and invalid write messages like: 
> 
> ==3015== Thread 4:
> ==3015== Invalid write of size 4
> ==3015==    at 0x1BD0E2EB: ost::Thread::~Thread() (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==    by 0x1BD0E82E: ost::Thread::close() (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==    by 0x1BD0FA0E:
> ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==    by 0x1BD0E90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==  Address 0x1BF65B34 is 140 bytes inside a block of size 416
> free'd
> ==3015==    at 0x1B90313F: operator delete(void*)
> (vg_replace_malloc.c:156)
> ==3015==    by 0x8057F87:
> TCPSessionThread<AgentContainer*>::~TCPSessionThread()
> (AgentContainer.cpp:125)
> ==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
> ==3015==    by 0x1BD0E804: ost::Thread::close() (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==
> 
> 
> But the most interesting bit is: 
> 
> ==3015== Thread 4:
> ==3015== Invalid free() / delete / delete[]
> ==3015==    at 0x1B90313F: operator delete(void*)
> (vg_replace_malloc.c:156)
> ==3015==    by 0x1BD0E320: ost::Thread::~Thread() (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==    by 0x1BD0E82E: ost::Thread::close() (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==    by 0x1BD0FA0E:
> ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==  Address 0x1BF65B34 is 140 bytes inside a block of size 416
> free'd
> ==3015==    at 0x1B90313F: operator delete(void*)
> (vg_replace_malloc.c:156)
> ==3015==    by 0x8057F87:
> TCPSessionThread<AgentContainer*>::~TCPSessionThread()
> (AgentContainer.cpp:125)
> ==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
> ==3015==    by 0x1BD0E804: ost::Thread::close() (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==
> 
> 
> I am not reserving or freeing any memory (well I do create a new srting
> that will be deleted elsewhere). Any Ideas? Am I just doing All Things
> Wrong? Should I consider a career change? 
> 
> I'll provide any additional information you need. 
> 
> Thanks again!
> 
> --
> Rami Saarinen
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> 
> _______________________________________________
> Bug-commoncpp mailing list
> Bug-commoncpp@gnu.org
> http://lists.gnu.org/mailman/listinfo/bug-commoncpp

--------------080105010402030505040309
Content-Type: text/x-vcard; charset=utf-8;
 name="dyfet.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="dyfet.vcf"

begin:vcard
fn:David Sugar
n:Sugar;David
org:GNU Project
adr:;;23 Olin Drive;Cape May Court House;NJ;08210;USA
email;internet:dyfet@ostel.com
tel;home:1 609 465 5336
tel;cell:1 908 917 6084
x-mozilla-html:FALSE
url:http://www.ostel.com
version:2.1
end:vcard


--------------080105010402030505040309--



From MAILER-DAEMON Thu Feb 10 08:30:55 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1CzEPH-0000uD-0F
	for mharc-bug-commoncpp@gnu.org; Thu, 10 Feb 2005 08:30:55 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1CzEPE-0000tC-Ps
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 08:30:52 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1CzEPC-0000s3-JE
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 08:30:51 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1CzENH-0008NK-Gy
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 08:28:51 -0500
Received: from [216.218.222.122] (helo=mail.ostel.com)
	by monty-python.gnu.org with esmtp (Exim 4.34) id 1CzDst-0006ke-Ro
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 07:57:28 -0500
Received: from [192.168.1.101] (pool-138-89-240-2.atc.east.verizon.net
	[138.89.240.2])
	by mail.ostel.com (Postfix) with ESMTP id 39AE22F2873;
	Thu, 10 Feb 2005 05:20:57 -0800 (PST)
Message-ID: <420B5A35.6080101@ostel.com>
Date: Thu, 10 Feb 2005 07:57:25 -0500
From: David Sugar <dyfet@ostel.com>
Organization: GNU Project
User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Rami Saarinen <rs55862@yahoo.com>
References: <20050210101329.96847.qmail@web53001.mail.yahoo.com>
In-Reply-To: <20050210101329.96847.qmail@web53001.mail.yahoo.com>
Content-Type: multipart/mixed; boundary="------------070804050105000602070601"
Cc: bug-commoncpp@gnu.org
Subject: Re: Haunting free(): invalid pointer 0x8a11604!
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 10 Feb 2005 13:30:53 -0000

This is a multi-part message in MIME format.
--------------070804050105000602070601
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

In fact, I will go a step further...Thread() is built with a virtual 
destructor...it appears to me that virtual destructors are not working 
correcting on your compiler.  This would explain the memory offset of 
the delete free() operation in Thread::close, which I am guessing is 
likely the offset position of the "Thread" object within the derived 
class.  Again re-ordering the classes to assure Thread is always first 
may help since most C++ compilers do create the objects in memory based 
on their order.  Those that don't probably do handle virtual destructors 
correctly.

Rami Saarinen wrote:
> Hello again, 
> 
> Ia currently doing some restructuring on the program that I had probelms
> with few moths ago. I just poke my editor into some very nasty stuff and
> I'd like to ask if any of you have any idea why I do get a buch of Invalid
> pointer error messages. 
> 
> The program is heavily threaded "MessageDispatch" style of client/server
> program. The proble is in the server. The server also uses xerces-c++ and
> sqlite3. 
> 
> I just updated common c++ form 1.0.9 to 1.3.1. None of the threads have
> final() method defined and the threads are detached() and *not* started().
> 
> The invalid pointer error does not appear on 1.0.9 version. 
> 
> I have been using valgrind (altought it's pthread support is incomplete)
> to find another proble that will crash the program when it tries to create
> XercesDOMParser. I think these problems *may* be interlinked as the crash
> occurs in malloc() -> so maybe the TCPSession + other thread stuff messes
> the memory so that malloc fails.
> 
> Anyway when the  free(): invalid pointer 0xxxxxxxxx! appears Valgrind will
> display quite many of Invalid read messages like: 
> 
> ==3015== Invalid read of size 4
> ==3015==    at 0x1BD0E831: ost::Thread::close() (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==    by 0x1BD0FA0E:
> ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==    by 0x1BD0E90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==    by 0x1BCCD847: thread_wrapper (vg_libpthread.c:867)
> ==3015==  Address 0x1BF65B98 is 240 bytes inside a block of size 416
> free'd
> ==3015==    at 0x1B90313F: operator delete(void*)
> (vg_replace_malloc.c:156)
> ==3015==    by 0x8057F87:
> TCPSessionThread<AgentContainer*>::~TCPSessionThread()
> (AgentContainer.cpp:125)
> ==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
> ==3015==    by 0x1BD0E804: ost::Thread::close() (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> 
> 
> and invalid write messages like: 
> 
> ==3015== Thread 4:
> ==3015== Invalid write of size 4
> ==3015==    at 0x1BD0E2EB: ost::Thread::~Thread() (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==    by 0x1BD0E82E: ost::Thread::close() (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==    by 0x1BD0FA0E:
> ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==    by 0x1BD0E90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==  Address 0x1BF65B34 is 140 bytes inside a block of size 416
> free'd
> ==3015==    at 0x1B90313F: operator delete(void*)
> (vg_replace_malloc.c:156)
> ==3015==    by 0x8057F87:
> TCPSessionThread<AgentContainer*>::~TCPSessionThread()
> (AgentContainer.cpp:125)
> ==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
> ==3015==    by 0x1BD0E804: ost::Thread::close() (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==
> 
> 
> But the most interesting bit is: 
> 
> ==3015== Thread 4:
> ==3015== Invalid free() / delete / delete[]
> ==3015==    at 0x1B90313F: operator delete(void*)
> (vg_replace_malloc.c:156)
> ==3015==    by 0x1BD0E320: ost::Thread::~Thread() (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==    by 0x1BD0E82E: ost::Thread::close() (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==    by 0x1BD0FA0E:
> ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==  Address 0x1BF65B34 is 140 bytes inside a block of size 416
> free'd
> ==3015==    at 0x1B90313F: operator delete(void*)
> (vg_replace_malloc.c:156)
> ==3015==    by 0x8057F87:
> TCPSessionThread<AgentContainer*>::~TCPSessionThread()
> (AgentContainer.cpp:125)
> ==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
> ==3015==    by 0x1BD0E804: ost::Thread::close() (in
> /usr/lib/libccgnu2-1.3.so.0.0.1)
> ==3015==
> 
> 
> I am not reserving or freeing any memory (well I do create a new srting
> that will be deleted elsewhere). Any Ideas? Am I just doing All Things
> Wrong? Should I consider a career change? 
> 
> I'll provide any additional information you need. 
> 
> Thanks again!
> 
> --
> Rami Saarinen
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> 
> _______________________________________________
> Bug-commoncpp mailing list
> Bug-commoncpp@gnu.org
> http://lists.gnu.org/mailman/listinfo/bug-commoncpp

--------------070804050105000602070601
Content-Type: text/x-vcard; charset=utf-8;
 name="dyfet.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="dyfet.vcf"

begin:vcard
fn:David Sugar
n:Sugar;David
org:GNU Project
adr:;;23 Olin Drive;Cape May Court House;NJ;08210;USA
email;internet:dyfet@ostel.com
tel;home:1 609 465 5336
tel;cell:1 908 917 6084
x-mozilla-html:FALSE
url:http://www.ostel.com
version:2.1
end:vcard


--------------070804050105000602070601--



From MAILER-DAEMON Thu Feb 10 08:31:04 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1CzEPQ-0000xy-4M
	for mharc-bug-commoncpp@gnu.org; Thu, 10 Feb 2005 08:31:04 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1CzEPO-0000xE-26
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 08:31:02 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1CzEN2-00006o-G6
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 08:28:41 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1CzEMw-0008NK-Ox
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 08:28:30 -0500
Received: from [195.112.37.194] (helo=jolt.ukmail.org)
	by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168)
	(Exim 4.34) id 1CzE0k-0007em-Gf
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 08:05:35 -0500
Received: from jolt.ukmail.org ([127.0.0.1] helo=[192.168.123.20])
	by jolt.ukmail.org with esmtp (Exim 3.35 #1 (Debian))
	id 1CzE0V-00074x-00; Thu, 10 Feb 2005 13:05:19 +0000
Message-ID: <420B5C11.6010307@ukmail.org>
Date: Thu, 10 Feb 2005 13:05:21 +0000
From: Nick Liebmann <nick@ukmail.org>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Rami Saarinen <rs55862@yahoo.com>
References: <20050210101329.96847.qmail@web53001.mail.yahoo.com>
	<420B559C.40404@ostel.com>
In-Reply-To: <420B559C.40404@ostel.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cc: bug-commoncpp@gnu.org
Subject: Re: Haunting free(): invalid pointer 0x8a11604!
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 10 Feb 2005 13:31:02 -0000


Following on from this, I'd be inclined to check that all of your 
destructors are declared as virtual, and you are not deleting objects 
multiple times.


Nick

David Sugar wrote:

> Hmm...perhaps it is a dynamic casting issue.  The thread close method 
> itself is only really aware of a "Thread" object as the base class 
> itself, at that point in time.  If it is unable to handle the delete 
> of the derived virtual object by recasting the pointer references, 
> then perhaps the order of base classes listed in the final derived 
> class can be changed, so that TCPSession() is the first base in your 
> derived class.  In fact, I would also consider reversing the order of 
> declaration of TCPSession in cc++/socket.h, so that public Thread 
> appears before public TCPStream for the same reason.
>
> I have never noticed this problem in normal (non-detached) threads, 
> since the "delete" is always invoked against the derived class, and 
> not a virtual base.
>
> Rami Saarinen wrote:
>
>> Hello again,
>> Ia currently doing some restructuring on the program that I had probelms
>> with few moths ago. I just poke my editor into some very nasty stuff and
>> I'd like to ask if any of you have any idea why I do get a buch of 
>> Invalid
>> pointer error messages.
>> The program is heavily threaded "MessageDispatch" style of client/server
>> program. The proble is in the server. The server also uses xerces-c++ 
>> and
>> sqlite3.
>> I just updated common c++ form 1.0.9 to 1.3.1. None of the threads have
>> final() method defined and the threads are detached() and *not* 
>> started().
>>
>> The invalid pointer error does not appear on 1.0.9 version.
>> I have been using valgrind (altought it's pthread support is incomplete)
>> to find another proble that will crash the program when it tries to 
>> create
>> XercesDOMParser. I think these problems *may* be interlinked as the 
>> crash
>> occurs in malloc() -> so maybe the TCPSession + other thread stuff 
>> messes
>> the memory so that malloc fails.
>>
>> Anyway when the  free(): invalid pointer 0xxxxxxxxx! appears Valgrind 
>> will
>> display quite many of Invalid read messages like:
>> ==3015== Invalid read of size 4
>> ==3015==    at 0x1BD0E831: ost::Thread::close() (in
>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>> ==3015==    by 0x1BD0FA0E:
>> ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>> ==3015==    by 0x1BD0E90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
>> ==3015==    by 0x1BCCD847: thread_wrapper (vg_libpthread.c:867)
>> ==3015==  Address 0x1BF65B98 is 240 bytes inside a block of size 416
>> free'd
>> ==3015==    at 0x1B90313F: operator delete(void*)
>> (vg_replace_malloc.c:156)
>> ==3015==    by 0x8057F87:
>> TCPSessionThread<AgentContainer*>::~TCPSessionThread()
>> (AgentContainer.cpp:125)
>> ==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
>> ==3015==    by 0x1BD0E804: ost::Thread::close() (in
>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>
>>
>> and invalid write messages like:
>> ==3015== Thread 4:
>> ==3015== Invalid write of size 4
>> ==3015==    at 0x1BD0E2EB: ost::Thread::~Thread() (in
>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>> ==3015==    by 0x1BD0E82E: ost::Thread::close() (in
>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>> ==3015==    by 0x1BD0FA0E:
>> ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>> ==3015==    by 0x1BD0E90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
>> ==3015==  Address 0x1BF65B34 is 140 bytes inside a block of size 416
>> free'd
>> ==3015==    at 0x1B90313F: operator delete(void*)
>> (vg_replace_malloc.c:156)
>> ==3015==    by 0x8057F87:
>> TCPSessionThread<AgentContainer*>::~TCPSessionThread()
>> (AgentContainer.cpp:125)
>> ==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
>> ==3015==    by 0x1BD0E804: ost::Thread::close() (in
>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>> ==3015==
>>
>>
>> But the most interesting bit is:
>> ==3015== Thread 4:
>> ==3015== Invalid free() / delete / delete[]
>> ==3015==    at 0x1B90313F: operator delete(void*)
>> (vg_replace_malloc.c:156)
>> ==3015==    by 0x1BD0E320: ost::Thread::~Thread() (in
>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>> ==3015==    by 0x1BD0E82E: ost::Thread::close() (in
>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>> ==3015==    by 0x1BD0FA0E:
>> ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>> ==3015==  Address 0x1BF65B34 is 140 bytes inside a block of size 416
>> free'd
>> ==3015==    at 0x1B90313F: operator delete(void*)
>> (vg_replace_malloc.c:156)
>> ==3015==    by 0x8057F87:
>> TCPSessionThread<AgentContainer*>::~TCPSessionThread()
>> (AgentContainer.cpp:125)
>> ==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
>> ==3015==    by 0x1BD0E804: ost::Thread::close() (in
>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>> ==3015==
>>
>>
>> I am not reserving or freeing any memory (well I do create a new srting
>> that will be deleted elsewhere). Any Ideas? Am I just doing All Things
>> Wrong? Should I consider a career change?
>> I'll provide any additional information you need.
>> Thanks again!
>>
>> -- 
>> Rami Saarinen
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Tired of spam?  Yahoo! Mail has the best spam protection around 
>> http://mail.yahoo.com
>>
>> _______________________________________________
>> Bug-commoncpp mailing list
>> Bug-commoncpp@gnu.org
>> http://lists.gnu.org/mailman/listinfo/bug-commoncpp
>
>_______________________________________________
>Bug-commoncpp mailing list
>Bug-commoncpp@gnu.org
>http://lists.gnu.org/mailman/listinfo/bug-commoncpp
>  
>



From MAILER-DAEMON Thu Feb 10 08:52:40 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1CzEkK-0007vk-Kc
	for mharc-bug-commoncpp@gnu.org; Thu, 10 Feb 2005 08:52:40 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1CzEk2-0007pk-Lh
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 08:52:23 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1CzEjv-0007mB-DV
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 08:52:16 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1CzEju-0007iz-OM
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 08:52:14 -0500
Received: from [216.218.222.122] (helo=mail.ostel.com)
	by monty-python.gnu.org with esmtp (Exim 4.34) id 1CzETq-00037P-F5
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 08:35:38 -0500
Received: from [192.168.1.101] (pool-138-89-240-2.atc.east.verizon.net
	[138.89.240.2])
	by mail.ostel.com (Postfix) with ESMTP id F3AA32F2873;
	Thu, 10 Feb 2005 05:59:05 -0800 (PST)
Message-ID: <420B6326.1050809@ostel.com>
Date: Thu, 10 Feb 2005 08:35:34 -0500
From: David Sugar <dyfet@ostel.com>
Organization: GNU Project
User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Nick Liebmann <nick@ukmail.org>
References: <20050210101329.96847.qmail@web53001.mail.yahoo.com>	<420B559C.40404@ostel.com>
	<420B5C11.6010307@ukmail.org>
In-Reply-To: <420B5C11.6010307@ukmail.org>
Content-Type: multipart/mixed; boundary="------------090107000404070809090007"
Cc: bug-commoncpp@gnu.org, Rami Saarinen <rs55862@yahoo.com>
Subject: Re: Haunting free(): invalid pointer 0x8a11604!
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 10 Feb 2005 13:52:33 -0000

This is a multi-part message in MIME format.
--------------090107000404070809090007
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Thread definately is declared with a virtual destructor, and so is 
Socket.  TCPStream, inherited from Socket, also redeclares a virtual 
destructor, and TCPSession has no declared destructor at all, although 
it inherits both TCPStream and Thread.  I am not sure what his 
"TCPSessionThread" has, although presumably it would inherit a 
destructor as a virtual from the underlying bases...

The Thread::close() method deletes the object through it's Thread base.

Nick Liebmann wrote:
> 
> Following on from this, I'd be inclined to check that all of your 
> destructors are declared as virtual, and you are not deleting objects 
> multiple times.
> 
> 
> Nick
> 
> David Sugar wrote:
> 
>> Hmm...perhaps it is a dynamic casting issue.  The thread close method 
>> itself is only really aware of a "Thread" object as the base class 
>> itself, at that point in time.  If it is unable to handle the delete 
>> of the derived virtual object by recasting the pointer references, 
>> then perhaps the order of base classes listed in the final derived 
>> class can be changed, so that TCPSession() is the first base in your 
>> derived class.  In fact, I would also consider reversing the order of 
>> declaration of TCPSession in cc++/socket.h, so that public Thread 
>> appears before public TCPStream for the same reason.
>>
>> I have never noticed this problem in normal (non-detached) threads, 
>> since the "delete" is always invoked against the derived class, and 
>> not a virtual base.
>>
>> Rami Saarinen wrote:
>>
>>> Hello again,
>>> Ia currently doing some restructuring on the program that I had probelms
>>> with few moths ago. I just poke my editor into some very nasty stuff and
>>> I'd like to ask if any of you have any idea why I do get a buch of 
>>> Invalid
>>> pointer error messages.
>>> The program is heavily threaded "MessageDispatch" style of client/server
>>> program. The proble is in the server. The server also uses xerces-c++ 
>>> and
>>> sqlite3.
>>> I just updated common c++ form 1.0.9 to 1.3.1. None of the threads have
>>> final() method defined and the threads are detached() and *not* 
>>> started().
>>>
>>> The invalid pointer error does not appear on 1.0.9 version.
>>> I have been using valgrind (altought it's pthread support is incomplete)
>>> to find another proble that will crash the program when it tries to 
>>> create
>>> XercesDOMParser. I think these problems *may* be interlinked as the 
>>> crash
>>> occurs in malloc() -> so maybe the TCPSession + other thread stuff 
>>> messes
>>> the memory so that malloc fails.
>>>
>>> Anyway when the  free(): invalid pointer 0xxxxxxxxx! appears Valgrind 
>>> will
>>> display quite many of Invalid read messages like:
>>> ==3015== Invalid read of size 4
>>> ==3015==    at 0x1BD0E831: ost::Thread::close() (in
>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>> ==3015==    by 0x1BD0FA0E:
>>> ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>> ==3015==    by 0x1BD0E90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
>>> ==3015==    by 0x1BCCD847: thread_wrapper (vg_libpthread.c:867)
>>> ==3015==  Address 0x1BF65B98 is 240 bytes inside a block of size 416
>>> free'd
>>> ==3015==    at 0x1B90313F: operator delete(void*)
>>> (vg_replace_malloc.c:156)
>>> ==3015==    by 0x8057F87:
>>> TCPSessionThread<AgentContainer*>::~TCPSessionThread()
>>> (AgentContainer.cpp:125)
>>> ==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
>>> ==3015==    by 0x1BD0E804: ost::Thread::close() (in
>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>>
>>>
>>> and invalid write messages like:
>>> ==3015== Thread 4:
>>> ==3015== Invalid write of size 4
>>> ==3015==    at 0x1BD0E2EB: ost::Thread::~Thread() (in
>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>> ==3015==    by 0x1BD0E82E: ost::Thread::close() (in
>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>> ==3015==    by 0x1BD0FA0E:
>>> ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>> ==3015==    by 0x1BD0E90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
>>> ==3015==  Address 0x1BF65B34 is 140 bytes inside a block of size 416
>>> free'd
>>> ==3015==    at 0x1B90313F: operator delete(void*)
>>> (vg_replace_malloc.c:156)
>>> ==3015==    by 0x8057F87:
>>> TCPSessionThread<AgentContainer*>::~TCPSessionThread()
>>> (AgentContainer.cpp:125)
>>> ==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
>>> ==3015==    by 0x1BD0E804: ost::Thread::close() (in
>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>> ==3015==
>>>
>>>
>>> But the most interesting bit is:
>>> ==3015== Thread 4:
>>> ==3015== Invalid free() / delete / delete[]
>>> ==3015==    at 0x1B90313F: operator delete(void*)
>>> (vg_replace_malloc.c:156)
>>> ==3015==    by 0x1BD0E320: ost::Thread::~Thread() (in
>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>> ==3015==    by 0x1BD0E82E: ost::Thread::close() (in
>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>> ==3015==    by 0x1BD0FA0E:
>>> ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>> ==3015==  Address 0x1BF65B34 is 140 bytes inside a block of size 416
>>> free'd
>>> ==3015==    at 0x1B90313F: operator delete(void*)
>>> (vg_replace_malloc.c:156)
>>> ==3015==    by 0x8057F87:
>>> TCPSessionThread<AgentContainer*>::~TCPSessionThread()
>>> (AgentContainer.cpp:125)
>>> ==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
>>> ==3015==    by 0x1BD0E804: ost::Thread::close() (in
>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>> ==3015==
>>>
>>>
>>> I am not reserving or freeing any memory (well I do create a new srting
>>> that will be deleted elsewhere). Any Ideas? Am I just doing All Things
>>> Wrong? Should I consider a career change?
>>> I'll provide any additional information you need.
>>> Thanks again!
>>>
>>> -- 
>>> Rami Saarinen
>>>
>>> __________________________________________________
>>> Do You Yahoo!?
>>> Tired of spam?  Yahoo! Mail has the best spam protection around 
>>> http://mail.yahoo.com
>>>
>>> _______________________________________________
>>> Bug-commoncpp mailing list
>>> Bug-commoncpp@gnu.org
>>> http://lists.gnu.org/mailman/listinfo/bug-commoncpp
>>
>>
>> _______________________________________________
>> Bug-commoncpp mailing list
>> Bug-commoncpp@gnu.org
>> http://lists.gnu.org/mailman/listinfo/bug-commoncpp
>>  
>>
> 
> 
> _______________________________________________
> Bug-commoncpp mailing list
> Bug-commoncpp@gnu.org
> http://lists.gnu.org/mailman/listinfo/bug-commoncpp

--------------090107000404070809090007
Content-Type: text/x-vcard; charset=utf-8;
 name="dyfet.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="dyfet.vcf"

begin:vcard
fn:David Sugar
n:Sugar;David
org:GNU Project
adr:;;23 Olin Drive;Cape May Court House;NJ;08210;USA
email;internet:dyfet@ostel.com
tel;home:1 609 465 5336
tel;cell:1 908 917 6084
x-mozilla-html:FALSE
url:http://www.ostel.com
version:2.1
end:vcard


--------------090107000404070809090007--



From MAILER-DAEMON Thu Feb 10 09:27:53 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1CzFIO-0000dk-7m
	for mharc-bug-commoncpp@gnu.org; Thu, 10 Feb 2005 09:27:52 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1CzFIL-0000cN-NA
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 09:27:49 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1CzFH8-0000Bw-B5
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 09:26:39 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1CzFH7-0008QY-JN
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 09:26:33 -0500
Received: from [195.112.37.194] (helo=jolt.ukmail.org)
	by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168)
	(Exim 4.34) id 1CzEoG-0005fO-5Z
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 08:56:44 -0500
Received: from jolt.ukmail.org ([127.0.0.1] helo=[192.168.123.20])
	by jolt.ukmail.org with esmtp (Exim 3.35 #1 (Debian))
	id 1CzEo8-0000h1-00; Thu, 10 Feb 2005 13:56:36 +0000
Message-ID: <420B6811.1030102@ukmail.org>
Date: Thu, 10 Feb 2005 13:56:33 +0000
From: Nick Liebmann <nick@ukmail.org>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: David Sugar <dyfet@ostel.com>
References: <20050210101329.96847.qmail@web53001.mail.yahoo.com>	<420B559C.40404@ostel.com>
	<420B5C11.6010307@ukmail.org> <420B6326.1050809@ostel.com>
In-Reply-To: <420B6326.1050809@ostel.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cc: bug-commoncpp@gnu.org, Rami Saarinen <rs55862@yahoo.com>
Subject: Re: Haunting free(): invalid pointer 0x8a11604!
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 10 Feb 2005 14:27:50 -0000

I am not sure the virtuality of a destructor is inherited but definitly 
with the gnu compiler I have had issues where not declaring a virtual 
destructor causes a whole host of problems.

 From what I remember when playing with this stuff on g++ 2.95 the only 
time calling 'delete this' caused me grief was when it was called from 
inside a constructor, where presumably the object had not been 
completely constructed. These tests where only for single inheritance 
though.

 From what you are saying though, he may be able overcome this problem 
by overriding Thread::close, to perform the delete this

bool m_bFakeDetach;
virtual bool isDetached()
{
    if(m_bFakeDetach)
       return(false);

    return(Thread::isDetached());
}

virtual void close()
{
    m_bFakeDetach = true; //Prevent base class calling delete this
    Thread::close();
    delete this;      //Top-level delete this
}

Of course at the moment these functions are not virtual though.


David Sugar wrote:

> Thread definately is declared with a virtual destructor, and so is 
> Socket.  TCPStream, inherited from Socket, also redeclares a virtual 
> destructor, and TCPSession has no declared destructor at all, although 
> it inherits both TCPStream and Thread.  I am not sure what his 
> "TCPSessionThread" has, although presumably it would inherit a 
> destructor as a virtual from the underlying bases...
>
> The Thread::close() method deletes the object through it's Thread base.
>
> Nick Liebmann wrote:
>
>>
>> Following on from this, I'd be inclined to check that all of your 
>> destructors are declared as virtual, and you are not deleting objects 
>> multiple times.
>>
>>
>> Nick
>>
>> David Sugar wrote:
>>
>>> Hmm...perhaps it is a dynamic casting issue.  The thread close 
>>> method itself is only really aware of a "Thread" object as the base 
>>> class itself, at that point in time.  If it is unable to handle the 
>>> delete of the derived virtual object by recasting the pointer 
>>> references, then perhaps the order of base classes listed in the 
>>> final derived class can be changed, so that TCPSession() is the 
>>> first base in your derived class.  In fact, I would also consider 
>>> reversing the order of declaration of TCPSession in cc++/socket.h, 
>>> so that public Thread appears before public TCPStream for the same 
>>> reason.
>>>
>>> I have never noticed this problem in normal (non-detached) threads, 
>>> since the "delete" is always invoked against the derived class, and 
>>> not a virtual base.
>>>
>>> Rami Saarinen wrote:
>>>
>>>> Hello again,
>>>> Ia currently doing some restructuring on the program that I had 
>>>> probelms
>>>> with few moths ago. I just poke my editor into some very nasty 
>>>> stuff and
>>>> I'd like to ask if any of you have any idea why I do get a buch of 
>>>> Invalid
>>>> pointer error messages.
>>>> The program is heavily threaded "MessageDispatch" style of 
>>>> client/server
>>>> program. The proble is in the server. The server also uses 
>>>> xerces-c++ and
>>>> sqlite3.
>>>> I just updated common c++ form 1.0.9 to 1.3.1. None of the threads 
>>>> have
>>>> final() method defined and the threads are detached() and *not* 
>>>> started().
>>>>
>>>> The invalid pointer error does not appear on 1.0.9 version.
>>>> I have been using valgrind (altought it's pthread support is 
>>>> incomplete)
>>>> to find another proble that will crash the program when it tries to 
>>>> create
>>>> XercesDOMParser. I think these problems *may* be interlinked as the 
>>>> crash
>>>> occurs in malloc() -> so maybe the TCPSession + other thread stuff 
>>>> messes
>>>> the memory so that malloc fails.
>>>>
>>>> Anyway when the  free(): invalid pointer 0xxxxxxxxx! appears 
>>>> Valgrind will
>>>> display quite many of Invalid read messages like:
>>>> ==3015== Invalid read of size 4
>>>> ==3015==    at 0x1BD0E831: ost::Thread::close() (in
>>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>>> ==3015==    by 0x1BD0FA0E:
>>>> ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
>>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>>> ==3015==    by 0x1BD0E90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
>>>> ==3015==    by 0x1BCCD847: thread_wrapper (vg_libpthread.c:867)
>>>> ==3015==  Address 0x1BF65B98 is 240 bytes inside a block of size 416
>>>> free'd
>>>> ==3015==    at 0x1B90313F: operator delete(void*)
>>>> (vg_replace_malloc.c:156)
>>>> ==3015==    by 0x8057F87:
>>>> TCPSessionThread<AgentContainer*>::~TCPSessionThread()
>>>> (AgentContainer.cpp:125)
>>>> ==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
>>>> ==3015==    by 0x1BD0E804: ost::Thread::close() (in
>>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>>>
>>>>
>>>> and invalid write messages like:
>>>> ==3015== Thread 4:
>>>> ==3015== Invalid write of size 4
>>>> ==3015==    at 0x1BD0E2EB: ost::Thread::~Thread() (in
>>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>>> ==3015==    by 0x1BD0E82E: ost::Thread::close() (in
>>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>>> ==3015==    by 0x1BD0FA0E:
>>>> ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
>>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>>> ==3015==    by 0x1BD0E90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
>>>> ==3015==  Address 0x1BF65B34 is 140 bytes inside a block of size 416
>>>> free'd
>>>> ==3015==    at 0x1B90313F: operator delete(void*)
>>>> (vg_replace_malloc.c:156)
>>>> ==3015==    by 0x8057F87:
>>>> TCPSessionThread<AgentContainer*>::~TCPSessionThread()
>>>> (AgentContainer.cpp:125)
>>>> ==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
>>>> ==3015==    by 0x1BD0E804: ost::Thread::close() (in
>>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>>> ==3015==
>>>>
>>>>
>>>> But the most interesting bit is:
>>>> ==3015== Thread 4:
>>>> ==3015== Invalid free() / delete / delete[]
>>>> ==3015==    at 0x1B90313F: operator delete(void*)
>>>> (vg_replace_malloc.c:156)
>>>> ==3015==    by 0x1BD0E320: ost::Thread::~Thread() (in
>>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>>> ==3015==    by 0x1BD0E82E: ost::Thread::close() (in
>>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>>> ==3015==    by 0x1BD0FA0E:
>>>> ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
>>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>>> ==3015==  Address 0x1BF65B34 is 140 bytes inside a block of size 416
>>>> free'd
>>>> ==3015==    at 0x1B90313F: operator delete(void*)
>>>> (vg_replace_malloc.c:156)
>>>> ==3015==    by 0x8057F87:
>>>> TCPSessionThread<AgentContainer*>::~TCPSessionThread()
>>>> (AgentContainer.cpp:125)
>>>> ==3015==    by 0x8057539: ost::TCPSession::final() (socket.h:1725)
>>>> ==3015==    by 0x1BD0E804: ost::Thread::close() (in
>>>> /usr/lib/libccgnu2-1.3.so.0.0.1)
>>>> ==3015==
>>>>
>>>>
>>>> I am not reserving or freeing any memory (well I do create a new 
>>>> srting
>>>> that will be deleted elsewhere). Any Ideas? Am I just doing All Things
>>>> Wrong? Should I consider a career change?
>>>> I'll provide any additional information you need.
>>>> Thanks again!
>>>>
>>>> -- 
>>>> Rami Saarinen
>>>>
>>>> __________________________________________________
>>>> Do You Yahoo!?
>>>> Tired of spam?  Yahoo! Mail has the best spam protection around 
>>>> http://mail.yahoo.com
>>>>
>>>> _______________________________________________
>>>> Bug-commoncpp mailing list
>>>> Bug-commoncpp@gnu.org
>>>> http://lists.gnu.org/mailman/listinfo/bug-commoncpp
>>>
>>>
>>>
>>> _______________________________________________
>>> Bug-commoncpp mailing list
>>> Bug-commoncpp@gnu.org
>>> http://lists.gnu.org/mailman/listinfo/bug-commoncpp
>>>  
>>>
>>
>>
>> _______________________________________________
>> Bug-commoncpp mailing list
>> Bug-commoncpp@gnu.org
>> http://lists.gnu.org/mailman/listinfo/bug-commoncpp
>



From MAILER-DAEMON Thu Feb 10 10:29:42 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1CzGGD-0007Wl-MM
	for mharc-bug-commoncpp@gnu.org; Thu, 10 Feb 2005 10:29:41 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1CzGGA-0007VR-QA
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 10:29:39 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1CzGG6-0007Sr-RD
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 10:29:37 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1CzGG6-0007RS-Cx
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 10:29:34 -0500
Received: from [206.190.39.198] (helo=web53008.mail.yahoo.com)
	by monty-python.gnu.org with smtp (Exim 4.34) id 1CzG0r-0004Uo-OR
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 10:13:49 -0500
Received: (qmail 24079 invoked by uid 60001); 10 Feb 2005 15:13:49 -0000
Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com;
	b=erZPD0a+KdxZnlUbhy6tBzWdHMLA9UXW5l9gVYgVB6EjPUbSexLjP6dus5v3EhKOL6Nvcjo5EMrlHCS+ARlyfozJ3v+nzTcr91R7ePimSIze7xev5H5TscrCGvhs9EFTMkDYAxasuigh/Vmfdgj9dqgJ7o6Zuv+1iA1yHrrN94Q=
	; 
Message-ID: <20050210151349.24077.qmail@web53008.mail.yahoo.com>
Received: from [153.1.60.204] by web53008.mail.yahoo.com via HTTP;
	Thu, 10 Feb 2005 07:13:48 PST
Date: Thu, 10 Feb 2005 07:13:48 -0800 (PST)
From: Rami Saarinen <rs55862@yahoo.com>
To: Nick Liebmann <nick@ukmail.org>
In-Reply-To: <420B5C11.6010307@ukmail.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Cc: bug-commoncpp@gnu.org
Subject: Re: Haunting free(): invalid pointer 0x8a11604!
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 10 Feb 2005 15:29:39 -0000


--- Nick Liebmann <nick@ukmail.org> wrote:

> 
> Following on from this, I'd be inclined to check that all of your 
> destructors are declared as virtual, and you are not deleting objects 
> multiple times.
> 
> 

At first I want to thank you all for the replies. 

To give a high level rundown of the the classes that are involved: 

The server creates and runs a "TCPListener" that inherits Thread. 

TCPListener waits for the incoming connections and upon connection it will
create a new "TCPSessionThread" to handle the connection. TCPSessionThread
is detached. 

TCPSessionThread inherits TCPSession and just overrides the run() method
to collect all the data and passes it to the server. 

Nothing too fancy there. Mostly just some own code mixed with the one
found in the examples. The only thing TCPSessionthread creates is a new
string to accumulate the incoming data. String is deleted once. 

If there are destructors they are now virtual. One of them was not
originally. 

I will have a closer look on your suggestions tomorrow. I think that maybe
I should try to isolate this problem from the rest of the application so I
may build some quick testcase to get the hang of it. 

Thanks again. 

--
Rami Saarinen


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250



From MAILER-DAEMON Thu Feb 10 11:04:24 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1CzGnm-0005rK-HJ
	for mharc-bug-commoncpp@gnu.org; Thu, 10 Feb 2005 11:04:22 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1CzGnk-0005qt-CG
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 11:04:20 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1CzGnf-0005pJ-Qv
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 11:04:19 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1CzGkT-0005FM-19
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 11:00:57 -0500
Received: from [195.112.37.194] (helo=jolt.ukmail.org)
	by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168)
	(Exim 4.34) id 1CzG7S-0005MR-QU
	for bug-commoncpp@gnu.org; Thu, 10 Feb 2005 10:20:39 -0500
Received: from jolt.ukmail.org ([127.0.0.1] helo=[192.168.123.20])
	by jolt.ukmail.org with esmtp (Exim 3.35 #1 (Debian))
	id 1CzG7P-0003nD-00; Thu, 10 Feb 2005 15:20:36 +0000
Message-ID: <420B7BC8.3020306@ukmail.org>
Date: Thu, 10 Feb 2005 15:20:40 +0000
From: Nick Liebmann <nick@ukmail.org>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Rami Saarinen <rs55862@yahoo.com>
References: <20050210151349.24077.qmail@web53008.mail.yahoo.com>
In-Reply-To: <20050210151349.24077.qmail@web53008.mail.yahoo.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cc: bug-commoncpp@gnu.org
Subject: Re: Haunting free(): invalid pointer 0x8a11604!
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 10 Feb 2005 16:04:21 -0000

I would also suggest declaring empty virtual destructors for any 
inherited classes for which you have no specific
need for a destructor. I dont really know why this should be necessary, 
but for some reason (at least in the past)
I have found this necessary, and now do it as a habit.

An isolated test-case is definitly the way to go!

Rami Saarinen wrote:

>--- Nick Liebmann <nick@ukmail.org> wrote:
>
>  
>
>>Following on from this, I'd be inclined to check that all of your 
>>destructors are declared as virtual, and you are not deleting objects 
>>multiple times.
>>
>>
>>    
>>
>
>At first I want to thank you all for the replies. 
>
>To give a high level rundown of the the classes that are involved: 
>
>The server creates and runs a "TCPListener" that inherits Thread. 
>
>TCPListener waits for the incoming connections and upon connection it will
>create a new "TCPSessionThread" to handle the connection. TCPSessionThread
>is detached. 
>
>TCPSessionThread inherits TCPSession and just overrides the run() method
>to collect all the data and passes it to the server. 
>
>Nothing too fancy there. Mostly just some own code mixed with the one
>found in the examples. The only thing TCPSessionthread creates is a new
>string to accumulate the incoming data. String is deleted once. 
>
>If there are destructors they are now virtual. One of them was not
>originally. 
>
>I will have a closer look on your suggestions tomorrow. I think that maybe
>I should try to isolate this problem from the rest of the application so I
>may build some quick testcase to get the hang of it. 
>
>Thanks again. 
>
>--
>Rami Saarinen
>
>
>		
>__________________________________ 
>Do you Yahoo!? 
>Yahoo! Mail - 250MB free storage. Do more. Manage less. 
>http://info.mail.yahoo.com/mail_250
>
>  
>



From MAILER-DAEMON Fri Feb 11 10:05:13 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1CzcM4-0005Q7-5D
	for mharc-bug-commoncpp@gnu.org; Fri, 11 Feb 2005 10:05:12 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1CzcLz-0005PH-Ub
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 10:05:08 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1CzcLt-0005Nj-EM
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 10:05:05 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1CzcLt-0005Na-70
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 10:05:01 -0500
Received: from [206.190.39.200] (helo=web53010.mail.yahoo.com)
	by monty-python.gnu.org with smtp (Exim 4.34) id 1Czc8c-00029I-NB
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 09:51:19 -0500
Received: (qmail 28346 invoked by uid 60001); 11 Feb 2005 14:51:17 -0000
Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com;
	b=IZkTwmtuZEN3h/ufe/rVEqC9uy/38fbmNAiJcxjPUHLa0H1k4bYKEiCEs6Hjkol9nzl7/ZIBCAwCy34KS6LD97VJxQBpJ054hoLuNQYza7eE8i/9RlEEnvBeQSHYAN3gu2U9v/lnYRLAIiDV11VTYd6zDxOAK6BN+FlMDiBB3oc=
	; 
Message-ID: <20050211145117.28344.qmail@web53010.mail.yahoo.com>
Received: from [153.1.60.204] by web53010.mail.yahoo.com via HTTP;
	Fri, 11 Feb 2005 06:51:17 PST
Date: Fri, 11 Feb 2005 06:51:17 -0800 (PST)
From: Rami Saarinen <rs55862@yahoo.com>
To: Nick Liebmann <nick@ukmail.org>
In-Reply-To: <420B7BC8.3020306@ukmail.org>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="0-757434723-1108133477=:21378"
Cc: bug-commoncpp@gnu.org
Subject: Re: Haunting free(): invalid pointer 0x8a11604!
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 11 Feb 2005 15:05:10 -0000

--0-757434723-1108133477=:21378
Content-Type: text/plain; charset=us-ascii
Content-Id: 
Content-Disposition: inline

--- Nick Liebmann <nick@ukmail.org> wrote:

> I would also suggest declaring empty virtual destructors for any 
> inherited classes for which you have no specific
> need for a destructor. I dont really know why this should be necessary, 
> but for some reason (at least in the past)
> I have found this necessary, and now do it as a habit.
> 
> An isolated test-case is definitly the way to go!

Well I just can't get it any simpler than this. Invalid pointer is still
present exactly like before. Am I missing something? Brains?

I am using cc++ 1.3.1, gcc 3.3.3 20040412, Fedora Core 2 (Linux). cc++ was
compiled on this machine.  

testlistener is the test program.

TCPListener is the one that will create TCPSessionThread per connection
when there are connections pending. 
 
TCPSessionThread does nothing at all (and the invalid pointer error
appears in destructor).

I linked it with -lccgnu2 -ldl  (used also -lpthread, but it is not needed
really). 


Valgrind gives this when connecting the test program and sending some text
to it: 

==4234== Memcheck, a memory error detector for x86-linux.
==4234== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward et al.
==4234== Using valgrind-2.2.0, a program supervision framework for
x86-linux.
==4234== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward et al.
==4234== For more details, rerun with: -v
==4234==
==4234== warning: Valgrind's pthread_attr_setinheritsched does nothing
==4234==          your program may misbehave as a result
listener: 153.1.60.204 port: 8001
tcplistener constructor end.
==4234== warning: Valgrind's pthread_attr_setinheritsched does nothing
==4234==          your program may misbehave as a result
new TCPSessionThread
tcpsessionthread run
==4234== warning: Valgrind's pthread_attr_destroy does nothing
==4234==          your program may misbehave as a result
==4234== warning: Valgrind's pthread_cond_destroy is incomplete
==4234==          (it doesn't check if the cond is waited on)
==4234==          your program may misbehave as a result
==4234== Thread 3:
==4234== Invalid read of size 4
==4234==    at 0x1B93C831: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==    by 0x1B93DA0E:
ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==4234==    by 0x1B93C90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
==4234==    by 0x1B974847: thread_wrapper (vg_libpthread.c:867)
==4234==  Address 0x1BBBDF48 is 240 bytes inside a block of size 412
free'd
==4234==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==4234==    by 0x804B191: TCPSessionThread::~TCPSessionThread() (in
/home/rami/s
tuff/garbage/tcptest/testlistener)
==4234==    by 0x804AF81: ost::TCPSession::final() (in
/home/rami/stuff/garbage/
tcptest/testlistener)
==4234==    by 0x1B93C804: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==
==4234== Thread 3:
==4234== Invalid read of size 4
==4234==    at 0x1B93F188: ost::Semaphore::post() (in
/usr/lib/libccgnu2-1.3.so.
0.0.1)
==4234==    by 0x1B93C84E: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==    by 0x1B93DA0E:
ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==4234==    by 0x1B93C90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
==4234==  Address 0x1BBBDEF0 is 152 bytes inside a block of size 412
free'd
==4234==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==4234==    by 0x804B191: TCPSessionThread::~TCPSessionThread() (in
/home/rami/s
tuff/garbage/tcptest/testlistener)
==4234==    by 0x804AF81: ost::TCPSession::final() (in
/home/rami/stuff/garbage/
tcptest/testlistener)
==4234==    by 0x1B93C804: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==
==4234== Thread 3:
==4234== Invalid read of size 4
==4234==    at 0x1B93F18F: ost::Semaphore::post() (in
/usr/lib/libccgnu2-1.3.so.
0.0.1)
==4234==    by 0x1B93C84E: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==    by 0x1B93DA0E:
ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==4234==    by 0x1B93C90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
==4234==  Address 0x1BBBDEEC is 148 bytes inside a block of size 412
free'd
==4234==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==4234==    by 0x804B191: TCPSessionThread::~TCPSessionThread() (in
/home/rami/s
tuff/garbage/tcptest/testlistener)
==4234==    by 0x804AF81: ost::TCPSession::final() (in
/home/rami/stuff/garbage/
tcptest/testlistener)
==4234==    by 0x1B93C804: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==
==4234== Thread 3:
==4234== Invalid read of size 4
==4234==    at 0x1B93C827: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==    by 0x1B93DA0E:
ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==4234==    by 0x1B93C90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
==4234==    by 0x1B974847: thread_wrapper (vg_libpthread.c:867)
==4234==  Address 0x1BBBDEE4 is 140 bytes inside a block of size 412
free'd
==4234==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==4234==    by 0x804B191: TCPSessionThread::~TCPSessionThread() (in
/home/rami/s
tuff/garbage/tcptest/testlistener)
==4234==    by 0x804AF81: ost::TCPSession::final() (in
/home/rami/stuff/garbage/
tcptest/testlistener)
==4234==    by 0x1B93C804: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==
==4234== Thread 3:
==4234== Invalid read of size 4
==4234==    at 0x1B93C2D2: ost::Thread::~Thread() (in
/usr/lib/libccgnu2-1.3.so.
0.0.1)
==4234==    by 0x1B93C82E: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==    by 0x1B93DA0E:
ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==4234==    by 0x1B93C90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
==4234==  Address 0x1BBBDF48 is 240 bytes inside a block of size 412
free'd
==4234==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==4234==    by 0x804B191: TCPSessionThread::~TCPSessionThread() (in
/home/rami/s
tuff/garbage/tcptest/testlistener)
==4234==    by 0x804AF81: ost::TCPSession::final() (in
/home/rami/stuff/garbage/
tcptest/testlistener)
==4234==    by 0x1B93C804: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==
==4234== Thread 3:
==4234== Invalid write of size 4
==4234==    at 0x1B93C2EB: ost::Thread::~Thread() (in
/usr/lib/libccgnu2-1.3.so.
0.0.1)
==4234==    by 0x1B93C82E: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==    by 0x1B93DA0E:
ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==4234==    by 0x1B93C90E: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
==4234==  Address 0x1BBBDEE4 is 140 bytes inside a block of size 412
free'd
==4234==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==4234==    by 0x804B191: TCPSessionThread::~TCPSessionThread() (in
/home/rami/s
tuff/garbage/tcptest/testlistener)
==4234==    by 0x804AF81: ost::TCPSession::final() (in
/home/rami/stuff/garbage/
tcptest/testlistener)
==4234==    by 0x1B93C804: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==
==4234== Thread 3:
==4234== Invalid write of size 4
==4234==    at 0x1B93F023: ost::Semaphore::~Semaphore() (in
/usr/lib/libccgnu2-1
.3.so.0.0.1)
==4234==    by 0x1B93C318: ost::Thread::~Thread() (in
/usr/lib/libccgnu2-1.3.so.
0.0.1)
==4234==    by 0x1B93C82E: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==    by 0x1B93DA0E:
ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==4234==  Address 0x1BBBDEE8 is 144 bytes inside a block of size 412
free'd
==4234==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==4234==    by 0x804B191: TCPSessionThread::~TCPSessionThread() (in
/home/rami/s
tuff/garbage/tcptest/testlistener)
==4234==    by 0x804AF81: ost::TCPSession::final() (in
/home/rami/stuff/garbage/
tcptest/testlistener)
==4234==    by 0x1B93C804: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234== warning: Valgrind's pthread_cond_destroy is incomplete
==4234==          (it doesn't check if the cond is waited on)
==4234==          your program may misbehave as a result
==4234==
==4234== Thread 3:
==4234== Invalid read of size 4
==4234==    at 0x1B975AFB: pthread_mutex_destroy (vg_libpthread.c:1364)
==4234==    by 0x1B93F03A: ost::Semaphore::~Semaphore() (in
/usr/lib/libccgnu2-1
.3.so.0.0.1)
==4234==    by 0x1B93C318: ost::Thread::~Thread() (in
/usr/lib/libccgnu2-1.3.so.
0.0.1)
==4234==    by 0x1B93C82E: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==  Address 0x1BBBDEF8 is 160 bytes inside a block of size 412
free'd
==4234==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==4234==    by 0x804B191: TCPSessionThread::~TCPSessionThread() (in
/home/rami/s
tuff/garbage/tcptest/testlistener)
==4234==    by 0x804AF81: ost::TCPSession::final() (in
/home/rami/stuff/garbage/
tcptest/testlistener)
==4234==    by 0x1B93C804: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==
==4234== Thread 3:
==4234== Invalid write of size 4
==4234==    at 0x1B975B1A: pthread_mutex_destroy (vg_libpthread.c:1372)
==4234==    by 0x1B93F03A: ost::Semaphore::~Semaphore() (in
/usr/lib/libccgnu2-1
.3.so.0.0.1)
==4234==    by 0x1B93C318: ost::Thread::~Thread() (in
/usr/lib/libccgnu2-1.3.so.
0.0.1)
==4234==    by 0x1B93C82E: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==  Address 0x1BBBDEF8 is 160 bytes inside a block of size 412
free'd
==4234==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==4234==    by 0x804B191: TCPSessionThread::~TCPSessionThread() (in
/home/rami/s
tuff/garbage/tcptest/testlistener)
==4234==    by 0x804AF81: ost::TCPSession::final() (in
/home/rami/stuff/garbage/
tcptest/testlistener)
==4234==    by 0x1B93C804: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==
==4234== Thread 3:
==4234== Invalid write of size 4
==4234==    at 0x1B975B21: pthread_mutex_destroy (vg_libpthread.c:1373)
==4234==    by 0x1B93F03A: ost::Semaphore::~Semaphore() (in
/usr/lib/libccgnu2-1
.3.so.0.0.1)
==4234==    by 0x1B93C318: ost::Thread::~Thread() (in
/usr/lib/libccgnu2-1.3.so.
0.0.1)
==4234==    by 0x1B93C82E: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==  Address 0x1BBBDEFC is 164 bytes inside a block of size 412
free'd
==4234==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==4234==    by 0x804B191: TCPSessionThread::~TCPSessionThread() (in
/home/rami/s
tuff/garbage/tcptest/testlistener)
==4234==    by 0x804AF81: ost::TCPSession::final() (in
/home/rami/stuff/garbage/
tcptest/testlistener)
==4234==    by 0x1B93C804: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==
==4234== Thread 3:
==4234== Invalid write of size 4
==4234==    at 0x1B975B28: pthread_mutex_destroy (vg_libpthread.c:1374)
==4234==    by 0x1B93F03A: ost::Semaphore::~Semaphore() (in
/usr/lib/libccgnu2-1
.3.so.0.0.1)
==4234==    by 0x1B93C318: ost::Thread::~Thread() (in
/usr/lib/libccgnu2-1.3.so.
0.0.1)
==4234==    by 0x1B93C82E: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==  Address 0x1BBBDF00 is 168 bytes inside a block of size 412
free'd
==4234==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==4234==    by 0x804B191: TCPSessionThread::~TCPSessionThread() (in
/home/rami/s
tuff/garbage/tcptest/testlistener)
==4234==    by 0x804AF81: ost::TCPSession::final() (in
/home/rami/stuff/garbage/
tcptest/testlistener)
==4234==    by 0x1B93C804: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==
==4234== Thread 3:
==4234== Invalid free() / delete / delete[]
==4234==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==4234==    by 0x1B93C320: ost::Thread::~Thread() (in
/usr/lib/libccgnu2-1.3.so.
0.0.1)
==4234==    by 0x1B93C82E: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==    by 0x1B93DA0E:
ost::ThreadImpl::ThreadExecHandler(ost::Thread*) (in
/usr/lib/libccgnu2-1.3.so.0.0.1)
==4234==  Address 0x1BBBDEE4 is 140 bytes inside a block of size 412
free'd
==4234==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==4234==    by 0x804B191: TCPSessionThread::~TCPSessionThread() (in
/home/rami/s
tuff/garbage/tcptest/testlistener)
==4234==    by 0x804AF81: ost::TCPSession::final() (in
/home/rami/stuff/garbage/
tcptest/testlistener)
==4234==    by 0x1B93C804: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234==
==4234== Thread 3:
==4234== Invalid read of size 4
==4234==    at 0x1B93C8B5: (within /usr/lib/libccgnu2-1.3.so.0.0.1)
==4234==    by 0x1B9740D3: thread_exit_wrapper (vg_libpthread.c:710)
==4234==    by 0x1B974857: thread_wrapper (vg_libpthread.c:873)
==4234==    by 0xB000EFE2: do__quit (vg_scheduler.c:1872)
==4234==  Address 0x1BBBDF48 is 240 bytes inside a block of size 412
free'd
==4234==    at 0x1B90313F: operator delete(void*)
(vg_replace_malloc.c:156)
==4234==    by 0x804B191: TCPSessionThread::~TCPSessionThread() (in
/home/rami/s
tuff/garbage/tcptest/testlistener)
==4234==    by 0x804AF81: ost::TCPSession::final() (in
/home/rami/stuff/garbage/
tcptest/testlistener)
==4234==    by 0x1B93C804: ost::Thread::close() (in
/usr/lib/libccgnu2-1.3.so.0.
0.1)
==4234== warning: Valgrind's pthread_attr_setinheritsched does nothing
==4234==          your program may misbehave as a result
new TCPSessionThread
tcpsessionthread run
==4234== warning: Valgrind's pthread_attr_destroy does nothing
==4234==          your program may misbehave as a result
==4234== warning: Valgrind's pthread_cond_destroy is incomplete
==4234==          (it doesn't check if the cond is waited on)
==4234==          your program may misbehave as a result
new TCPSessionThread
tcpsessionthread run
==4234== warning: Valgrind's pthread_attr_destroy does nothing
==4234==          your program may misbehave as a result
new TCPSessionThread
tcpsessionthread run
new TCPSessionThread
tcpsessionthread run
new TCPSessionThread
tcpsessionthread run
==4234==
==4234== ERROR SUMMARY: 84 errors from 13 contexts (suppressed: 33 from 1)
==4234== malloc/free: in use at exit: 6363 bytes in 68 blocks.
==4234== malloc/free: 131 allocs, 69 frees, 28035 bytes allocated.
==4234== For a detailed leak analysis,  rerun with: --leak-check=yes
==4234== For counts of detected errors, rerun with: -v


--
Rami Saarinen


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250
--0-757434723-1108133477=:21378
Content-Type: text/x-c++src; name="TCPListener.cpp"
Content-Description: TCPListener.cpp
Content-Disposition: inline; filename="TCPListener.cpp"

//XMLString::transcode clean

#ifndef oma__tcplistener_hpp__
#define oma__tcplistener_hpp__

#include <cc++/socket.h>
#include <cc++/thread.h>

#include "TCPSessionThread.cpp"
#include "TransportListener.cpp"

//#ifdef	CCXX_NAMESPACES
using namespace std;
using namespace ost;
//#endif

class TCPListener : public Thread {
public:
  TCPListener(int prt)  {
    InetHostAddress hostaddr=InetHostAddress();
    soc=new TCPSocket(hostaddr,prt);
    cout << "listener: " << hostaddr << " port: " << prt << endl;
    cout << "tcplistener constructor end.\n";
  }
  
  virtual ~TCPListener() {
    if(soc!=NULL)
      delete soc;
  }
  
  virtual void processConnection() {
	  TCPSessionThread  *tcp = new TCPSessionThread(*soc);
	  tcp->detach();
  }
  
  virtual void run() {
    try {
      while(1) {
	    while(soc->isPendingConnection()) {
	      processConnection();
        }
      }
    } catch(Socket *socket) {
      cerr << "What's all this then?" << endl;
    }
  }
  
protected:
  TCPSocket *soc;
};

#endif

--0-757434723-1108133477=:21378
Content-Type: text/x-c++src; name="TCPSessionThread.cpp"
Content-Description: TCPSessionThread.cpp
Content-Disposition: inline; filename="TCPSessionThread.cpp"

#ifndef __tcpsessionthread_hpp__
#define __tcpsessionthread_hpp__

#include <string>
#include <iostream>

#include <cc++/thread.h>
#include <cc++/socket.h>

using namespace std;
using namespace ost;

class TCPSessionThread : public TCPSession {
	public:
  TCPSessionThread(TCPSocket &server) : TCPSession(server)  {
    cerr << "new TCPSessionThread\n";
  }
  virtual ~TCPSessionThread() {
  }
  
  virtual void run() {
    cout << "tcpsessionthread run\n";
  }
  
protected:
};


#endif

--0-757434723-1108133477=:21378
Content-Type: text/x-c++src; name="testlistener.cpp"
Content-Description: testlistener.cpp
Content-Disposition: inline; filename="testlistener.cpp"


#include <string>

#include <TCPListener.cpp>
#include <cc++/socket.h>
#include <cc++/thread.h>

using namespace std; 
using namespace ost; 

class TestListener {
public:
  TestListener(): sem(0) {
    listener = new TCPListener(8001);
    listener->start();
  }
  
  ~TestListener() {
    delete listener;
  }

  void run() {
    sem.wait();
  }
  
private:
  Semaphore sem;
  TCPListener *listener;
};



int main() {
  TestListener t; 
  t.run();
  return 0;
}

--0-757434723-1108133477=:21378--



From MAILER-DAEMON Fri Feb 11 12:01:14 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1CzeAM-0003DK-DS
	for mharc-bug-commoncpp@gnu.org; Fri, 11 Feb 2005 12:01:14 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1CzeAK-0003Cu-0I
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 12:01:13 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1CzeAF-0003Bz-Uc
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 12:01:10 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1CzeAF-0003Bn-LG
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 12:01:07 -0500
Received: from [195.112.37.194] (helo=jolt.ukmail.org)
	by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168)
	(Exim 4.34) id 1Czdvr-0004tV-9z
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 11:46:15 -0500
Received: from 82-68-137-42.dsl.in-addr.zen.co.uk ([82.68.137.42]
	helo=[127.0.0.1])
	by jolt.ukmail.org with esmtp (Exim 3.35 #1 (Debian))
	id 1Czdvl-0003Rr-00
	for <bug-commoncpp@gnu.org>; Fri, 11 Feb 2005 16:46:09 +0000
Message-ID: <420CE18F.5010804@ukmail.org>
Date: Fri, 11 Feb 2005 16:47:11 +0000
From: Nick <nick@ukmail.org>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: bug-commoncpp@gnu.org
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Subject: [Fwd: Re: Haunting free(): invalid pointer 0x8a11604!]
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 11 Feb 2005 17:01:13 -0000


Ok, your problem is that the TCPSession::final calls delete this when
the thread ends.

Your choices are

1) Dont call tcp->detach(), call start()... the thread will be deleted
automaticall by TCPSession::final
2) override virtual void final() in TCPSessionThread, to do nothing.

For the library, TCPSession::final should say if(!isDetached()) delete this;

Rami Saarinen wrote:

>--- Nick Liebmann <nick@ukmail.org> wrote:
>
>  
>
>>I would also suggest declaring empty virtual destructors for any 
>>inherited classes for which you have no specific
>>need for a destructor. I dont really know why this should be necessary, 
>>but for some reason (at least in the past)
>>I have found this necessary, and now do it as a habit.
>>
>>An isolated test-case is definitly the way to go!
>>    
>>
>
>Well I just can't get it any simpler than this. Invalid pointer is still
>present exactly like before. Am I missing something? Brains?
>
>I am using cc++ 1.3.1, gcc 3.3.3 20040412, Fedora Core 2 (Linux). cc++ was
>compiled on this machine.  
>
>testlistener is the test program.
>
>TCPListener is the one that will create TCPSessionThread per connection
>when there are connections pending. 
> 
>TCPSessionThread does nothing at all (and the invalid pointer error
>appears in destructor).
>
>I linked it with -lccgnu2 -ldl  (used also -lpthread, but it is not needed
>really). 
>
>
>Valgrind gives this when connecting the test program and sending some text
>to it: 
>  
>






From MAILER-DAEMON Fri Feb 11 12:28:45 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1Czeay-0005g5-LJ
	for mharc-bug-commoncpp@gnu.org; Fri, 11 Feb 2005 12:28:44 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1Czeah-0005Zg-Mo
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 12:28:28 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1CzeaU-0005RD-0d
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 12:28:17 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1CzeaT-0005P8-3c
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 12:28:13 -0500
Received: from [216.218.222.122] (helo=mail.ostel.com)
	by monty-python.gnu.org with esmtp (Exim 4.34) id 1CzeJt-0007eW-Cm
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 12:11:05 -0500
Received: from [192.168.1.101] (pool-138-89-240-2.atc.east.verizon.net
	[138.89.240.2])
	by mail.ostel.com (Postfix) with ESMTP id DD6322F286D;
	Fri, 11 Feb 2005 09:34:42 -0800 (PST)
Message-ID: <420CE725.6010303@ostel.com>
Date: Fri, 11 Feb 2005 12:11:01 -0500
From: David Sugar <dyfet@ostel.com>
Organization: GNU Project
User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Nick <nick@ukmail.org>
References: <420CE18F.5010804@ukmail.org>
In-Reply-To: <420CE18F.5010804@ukmail.org>
Content-Type: multipart/mixed; boundary="------------030905040404050104070403"
Cc: bug-commoncpp@gnu.org
Subject: Re: [Fwd: Re: Haunting free(): invalid pointer 0x8a11604!]
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 11 Feb 2005 17:28:31 -0000

This is a multi-part message in MIME format.
--------------030905040404050104070403
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

In older versions of the library you would use "delete this" for 
detached threads.  In the current (1.3) releases, you should NEVER do 
this.  That final() was appearently leftover from before detach behavior 
was changed.  In 1.?2? and definately 1.3, detach deletes the the thread 
the object for you after you exit() the thread, and does it through the 
virtual destructors via the Thread base class.

Nick wrote:
> 
> Ok, your problem is that the TCPSession::final calls delete this when
> the thread ends.
> 
> Your choices are
> 
> 1) Dont call tcp->detach(), call start()... the thread will be deleted
> automaticall by TCPSession::final
> 2) override virtual void final() in TCPSessionThread, to do nothing.
> 
> For the library, TCPSession::final should say if(!isDetached()) delete 
> this;
> 
> Rami Saarinen wrote:
> 
>> --- Nick Liebmann <nick@ukmail.org> wrote:
>>
>>  
>>
>>> I would also suggest declaring empty virtual destructors for any 
>>> inherited classes for which you have no specific
>>> need for a destructor. I dont really know why this should be 
>>> necessary, but for some reason (at least in the past)
>>> I have found this necessary, and now do it as a habit.
>>>
>>> An isolated test-case is definitly the way to go!
>>>   
>>
>>
>> Well I just can't get it any simpler than this. Invalid pointer is still
>> present exactly like before. Am I missing something? Brains?
>>
>> I am using cc++ 1.3.1, gcc 3.3.3 20040412, Fedora Core 2 (Linux). cc++ 
>> was
>> compiled on this machine. 
>> testlistener is the test program.
>>
>> TCPListener is the one that will create TCPSessionThread per connection
>> when there are connections pending.
>> TCPSessionThread does nothing at all (and the invalid pointer error
>> appears in destructor).
>>
>> I linked it with -lccgnu2 -ldl  (used also -lpthread, but it is not 
>> needed
>> really).
>>
>> Valgrind gives this when connecting the test program and sending some 
>> text
>> to it:  
>>
> 
> 
> 
> 
> 
> _______________________________________________
> Bug-commoncpp mailing list
> Bug-commoncpp@gnu.org
> http://lists.gnu.org/mailman/listinfo/bug-commoncpp

--------------030905040404050104070403
Content-Type: text/x-vcard; charset=utf-8;
 name="dyfet.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="dyfet.vcf"

begin:vcard
fn:David Sugar
n:Sugar;David
org:GNU Project
adr:;;23 Olin Drive;Cape May Court House;NJ;08210;USA
email;internet:dyfet@ostel.com
tel;home:1 609 465 5336
tel;cell:1 908 917 6084
x-mozilla-html:FALSE
url:http://www.ostel.com
version:2.1
end:vcard


--------------030905040404050104070403--



From MAILER-DAEMON Fri Feb 11 12:59:39 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1Czf4t-0007OJ-6x
	for mharc-bug-commoncpp@gnu.org; Fri, 11 Feb 2005 12:59:39 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1Czf4e-0007Jd-PS
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 12:59:25 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1Czf4U-0007D9-DT
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 12:59:20 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1Czf4Q-00079d-Oy
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 12:59:10 -0500
Received: from [195.112.37.194] (helo=jolt.ukmail.org)
	by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168)
	(Exim 4.34) id 1CzefG-0001Vo-31
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 12:33:10 -0500
Received: from 82-68-137-42.dsl.in-addr.zen.co.uk ([82.68.137.42]
	helo=[127.0.0.1])
	by jolt.ukmail.org with esmtp (Exim 3.35 #1 (Debian))
	id 1CzefC-0004ry-00; Fri, 11 Feb 2005 17:33:06 +0000
Message-ID: <420CEC8F.1000605@ukmail.org>
Date: Fri, 11 Feb 2005 17:34:07 +0000
From: Nick <nick@ukmail.org>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: David Sugar <dyfet@ostel.com>
References: <420CE18F.5010804@ukmail.org> <420CE725.6010303@ostel.com>
In-Reply-To: <420CE725.6010303@ostel.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cc: bug-commoncpp@gnu.org
Subject: Re: [Fwd: Re: Haunting free(): invalid pointer 0x8a11604!]
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 11 Feb 2005 17:59:30 -0000

Apologies, I am using an older version of common c++

David Sugar wrote:

> In older versions of the library you would use "delete this" for 
> detached threads.  In the current (1.3) releases, you should NEVER do 
> this.  That final() was appearently leftover from before detach 
> behavior was changed.  In 1.?2? and definately 1.3, detach deletes the 
> the thread the object for you after you exit() the thread, and does it 
> through the virtual destructors via the Thread base class.
>
> Nick wrote:
>
>>
>> Ok, your problem is that the TCPSession::final calls delete this when
>> the thread ends.
>>
>> Your choices are
>>
>> 1) Dont call tcp->detach(), call start()... the thread will be deleted
>> automaticall by TCPSession::final
>> 2) override virtual void final() in TCPSessionThread, to do nothing.
>>
>> For the library, TCPSession::final should say if(!isDetached()) 
>> delete this;
>>
>> Rami Saarinen wrote:
>>
>>> --- Nick Liebmann <nick@ukmail.org> wrote:
>>>
>>>  
>>>
>>>> I would also suggest declaring empty virtual destructors for any 
>>>> inherited classes for which you have no specific
>>>> need for a destructor. I dont really know why this should be 
>>>> necessary, but for some reason (at least in the past)
>>>> I have found this necessary, and now do it as a habit.
>>>>
>>>> An isolated test-case is definitly the way to go!
>>>>   
>>>
>>>
>>>
>>> Well I just can't get it any simpler than this. Invalid pointer is 
>>> still
>>> present exactly like before. Am I missing something? Brains?
>>>
>>> I am using cc++ 1.3.1, gcc 3.3.3 20040412, Fedora Core 2 (Linux). 
>>> cc++ was
>>> compiled on this machine. testlistener is the test program.
>>>
>>> TCPListener is the one that will create TCPSessionThread per connection
>>> when there are connections pending.
>>> TCPSessionThread does nothing at all (and the invalid pointer error
>>> appears in destructor).
>>>
>>> I linked it with -lccgnu2 -ldl  (used also -lpthread, but it is not 
>>> needed
>>> really).
>>>
>>> Valgrind gives this when connecting the test program and sending 
>>> some text
>>> to it: 
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> Bug-commoncpp mailing list
>> Bug-commoncpp@gnu.org
>> http://lists.gnu.org/mailman/listinfo/bug-commoncpp
>




From MAILER-DAEMON Fri Feb 11 13:25:55 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1CzfUJ-0007KK-Bi
	for mharc-bug-commoncpp@gnu.org; Fri, 11 Feb 2005 13:25:55 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1CzfRs-0006kA-Lt
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 13:23:25 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1CzfRc-0006cB-7X
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 13:23:12 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1CzfRb-0006Xv-GI
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 13:23:07 -0500
Received: from [206.190.39.196] (helo=web53006.mail.yahoo.com)
	by monty-python.gnu.org with smtp (Exim 4.34) id 1Czf54-0003lJ-8S
	for bug-commoncpp@gnu.org; Fri, 11 Feb 2005 12:59:50 -0500
Received: (qmail 63901 invoked by uid 60001); 11 Feb 2005 17:59:49 -0000
Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com;
	b=xyKaA3MSMy9IrKjlJHxVQEhtF5FTM4qkyFg/1xSnnS4fBQzO+VuzKk8DJcYh6X+jMC/hqISiXf/4o0zAJ7nyBpNzTmQLEd22U+pPVuVj0tbt3DMzQPy9bKNXFRKQAnah/fIxYbpvvqXGiJw2EZIkGvYd8Y5VP8iG2YXQ6brssKk=
	; 
Message-ID: <20050211175949.63899.qmail@web53006.mail.yahoo.com>
Received: from [212.246.180.54] by web53006.mail.yahoo.com via HTTP;
	Fri, 11 Feb 2005 09:59:48 PST
Date: Fri, 11 Feb 2005 09:59:48 -0800 (PST)
From: Rami Saarinen <rs55862@yahoo.com>
To: Nick Liebmann <Nick.Liebmann@vistek.tv>
In-Reply-To: <420CDD8D.5090506@vistek.tv>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Cc: bug-commoncpp@gnu.org
Subject: Re: Haunting free(): invalid pointer 0x8a11604!
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 11 Feb 2005 18:25:54 -0000


--- Nick Liebmann <Nick.Liebmann@vistek.tv> wrote:

> 
> Ok, your problem is that the TCPSession::final calls delete this when 
> the thread ends.
> 
> Your choices are
> 
> 1) Dont call tcp->detach(), call start()... the thread will be deleted 
> automaticall by TCPSession::final
> 2) override virtual void final() in TCPSessionThread, to do nothing.
> 
> For the library, TCPSession::final should say if(!isDetached()) delete
> this;

Thanks Nick! I'll check this out on monday. 


--
Rami Saarinen



		
__________________________________ 
Do you Yahoo!? 
All your favorites on one personal page – Try My Yahoo!
http://my.yahoo.com 



From MAILER-DAEMON Sun Feb 13 05:53:12 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1D0HMZ-00051j-6H
	for mharc-bug-commoncpp@gnu.org; Sun, 13 Feb 2005 05:52:28 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1D0HMA-0004xw-2Z
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 05:52:03 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1D0HM0-0004uu-FH
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 05:51:56 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1D0HLy-0004ok-0P
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 05:51:50 -0500
Received: from [195.112.37.194] (helo=jolt.ukmail.org)
	by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168)
	(Exim 4.34) id 1D0H2C-0004aJ-P5
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 05:31:25 -0500
Received: from jolt.ukmail.org ([127.0.0.1] helo=[192.168.123.20])
	by jolt.ukmail.org with esmtp (Exim 3.35 #1 (Debian))
	id 1D0H25-0007wc-00; Sun, 13 Feb 2005 10:31:17 +0000
Message-ID: <420F2C79.4070303@ukmail.org>
Date: Sun, 13 Feb 2005 10:31:21 +0000
From: Nick Liebmann <nick@ukmail.org>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: David Sugar <dyfet@ostel.com>
References: <420CE18F.5010804@ukmail.org> <420CE725.6010303@ostel.com>
In-Reply-To: <420CE725.6010303@ostel.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cc: bug-commoncpp@gnu.org
Subject: Re: [Fwd: Re: Haunting free(): invalid pointer 0x8a11604!]
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 13 Feb 2005 10:52:07 -0000

As a penance for trying to sort out this problem with an old version of 
the library, I have taken a look with the latest version.

Here are my discoveries:

As previously stated 'delete this' is called from Thread::close(), and 
there seems to be no reason to assume anything is wrong with this call. 
All destructors are called appropriately.

The problem valgrind reports is that an access is being made to an 
already deleted chunk of memory, and it seems to be correct...

After the 'delete this' pthread_exit(NULL) is called, which causes a 
call to ccxx_thread_destructor, which itself calls 
ThreadImpl::ThreadDestructor.

ThreadImpl::ThreadDestructor checks th->priv which is illegal, because 
th (the thread) has been deleted.

This is where my knowledge of pthreads becomes flaky, but I reckon this 
is being called due to the ThreadKey object still having a reference to 
the thread

Inserting the line:
ThreadImpl::_self.setKey(NULL);
before the call to th->close() in 
ThreadImpl::ThreadExecHandler(Thread*th) sorts out the problem, however 
I am not actually sure of  the side effects of this call. Maybe is 
should be conditional, depending on the detached state of the thread.

David... its over to you

Nick



David Sugar wrote:

> In older versions of the library you would use "delete this" for 
> detached threads.  In the current (1.3) releases, you should NEVER do 
> this.  That final() was appearently leftover from before detach 
> behavior was changed.  In 1.?2? and definately 1.3, detach deletes the 
> the thread the object for you after you exit() the thread, and does it 
> through the virtual destructors via the Thread base class.
>
> Nick wrote:
>
>>
>> Ok, your problem is that the TCPSession::final calls delete this when
>> the thread ends.
>>
>> Your choices are
>>
>> 1) Dont call tcp->detach(), call start()... the thread will be deleted
>> automaticall by TCPSession::final
>> 2) override virtual void final() in TCPSessionThread, to do nothing.
>>
>> For the library, TCPSession::final should say if(!isDetached()) 
>> delete this;
>>
>> Rami Saarinen wrote:
>>
>>> --- Nick Liebmann <nick@ukmail.org> wrote:
>>>
>>>  
>>>
>>>> I would also suggest declaring empty virtual destructors for any 
>>>> inherited classes for which you have no specific
>>>> need for a destructor. I dont really know why this should be 
>>>> necessary, but for some reason (at least in the past)
>>>> I have found this necessary, and now do it as a habit.
>>>>
>>>> An isolated test-case is definitly the way to go!
>>>>   
>>>
>>>
>>>
>>> Well I just can't get it any simpler than this. Invalid pointer is 
>>> still
>>> present exactly like before. Am I missing something? Brains?
>>>
>>> I am using cc++ 1.3.1, gcc 3.3.3 20040412, Fedora Core 2 (Linux). 
>>> cc++ was
>>> compiled on this machine. testlistener is the test program.
>>>
>>> TCPListener is the one that will create TCPSessionThread per connection
>>> when there are connections pending.
>>> TCPSessionThread does nothing at all (and the invalid pointer error
>>> appears in destructor).
>>>
>>> I linked it with -lccgnu2 -ldl  (used also -lpthread, but it is not 
>>> needed
>>> really).
>>>
>>> Valgrind gives this when connecting the test program and sending 
>>> some text
>>> to it: 
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> Bug-commoncpp mailing list
>> Bug-commoncpp@gnu.org
>> http://lists.gnu.org/mailman/listinfo/bug-commoncpp
>



From MAILER-DAEMON Sun Feb 13 06:29:26 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1D0HwI-0006ut-2D
	for mharc-bug-commoncpp@gnu.org; Sun, 13 Feb 2005 06:29:22 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1D0HvW-0006Ut-Uw
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 06:28:36 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1D0Hui-0006At-Th
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 06:27:48 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1D0Hsw-0005k2-Qi
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 06:25:55 -0500
Received: from [216.218.222.122] (helo=mail.ostel.com)
	by monty-python.gnu.org with esmtp (Exim 4.34) id 1D0Hfc-0006qr-VR
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 06:12:09 -0500
Received: from [192.168.1.101] (pool-138-89-240-2.atc.east.verizon.net
	[138.89.240.2])
	by mail.ostel.com (Postfix) with ESMTP id 0BDAF2F2864;
	Sun, 13 Feb 2005 03:35:59 -0800 (PST)
Message-ID: <420F3604.4070106@ostel.com>
Date: Sun, 13 Feb 2005 06:12:04 -0500
From: David Sugar <dyfet@ostel.com>
Organization: GNU Project
User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Nick Liebmann <nick@ukmail.org>
References: <420CE18F.5010804@ukmail.org> <420CE725.6010303@ostel.com>
	<420F2C79.4070303@ukmail.org>
In-Reply-To: <420F2C79.4070303@ukmail.org>
Content-Type: multipart/mixed; boundary="------------080809020404050503040207"
Cc: bug-commoncpp@gnu.org
Subject: Re: [Fwd: Re: Haunting free(): invalid pointer 0x8a11604!]
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 13 Feb 2005 11:29:19 -0000

This is a multi-part message in MIME format.
--------------080809020404050503040207
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hmm....I think for now it should be conditional, at least until we can 
look at a detailed analysis of any misbehaving non-detached thread.  In 
the case of non-detached threads, after the thread is cancelled and 
joined, there is still some interactions happening in the destructor as 
terminate() completes which depend on the object still being "valid", so 
that may not be right to do for non-detached threads, but this is not 
the case of a detached thread that exits; through pthread_exit(), it 
just in effect walks off the cliff and dissapears.

Nick Liebmann wrote:
> As a penance for trying to sort out this problem with an old version of 
> the library, I have taken a look with the latest version.
> 
> Here are my discoveries:
> 
> As previously stated 'delete this' is called from Thread::close(), and 
> there seems to be no reason to assume anything is wrong with this call. 
> All destructors are called appropriately.
> 
> The problem valgrind reports is that an access is being made to an 
> already deleted chunk of memory, and it seems to be correct...
> 
> After the 'delete this' pthread_exit(NULL) is called, which causes a 
> call to ccxx_thread_destructor, which itself calls 
> ThreadImpl::ThreadDestructor.
> 
> ThreadImpl::ThreadDestructor checks th->priv which is illegal, because 
> th (the thread) has been deleted.
> 
> This is where my knowledge of pthreads becomes flaky, but I reckon this 
> is being called due to the ThreadKey object still having a reference to 
> the thread
> 
> Inserting the line:
> ThreadImpl::_self.setKey(NULL);
> before the call to th->close() in 
> ThreadImpl::ThreadExecHandler(Thread*th) sorts out the problem, however 
> I am not actually sure of  the side effects of this call. Maybe is 
> should be conditional, depending on the detached state of the thread.
> 
> David... its over to you
> 
> Nick
> 
> 
> 
> David Sugar wrote:
> 
>> In older versions of the library you would use "delete this" for 
>> detached threads.  In the current (1.3) releases, you should NEVER do 
>> this.  That final() was appearently leftover from before detach 
>> behavior was changed.  In 1.?2? and definately 1.3, detach deletes the 
>> the thread the object for you after you exit() the thread, and does it 
>> through the virtual destructors via the Thread base class.
>>
>> Nick wrote:
>>
>>>
>>> Ok, your problem is that the TCPSession::final calls delete this when
>>> the thread ends.
>>>
>>> Your choices are
>>>
>>> 1) Dont call tcp->detach(), call start()... the thread will be deleted
>>> automaticall by TCPSession::final
>>> 2) override virtual void final() in TCPSessionThread, to do nothing.
>>>
>>> For the library, TCPSession::final should say if(!isDetached()) 
>>> delete this;
>>>
>>> Rami Saarinen wrote:
>>>
>>>> --- Nick Liebmann <nick@ukmail.org> wrote:
>>>>
>>>>  
>>>>
>>>>> I would also suggest declaring empty virtual destructors for any 
>>>>> inherited classes for which you have no specific
>>>>> need for a destructor. I dont really know why this should be 
>>>>> necessary, but for some reason (at least in the past)
>>>>> I have found this necessary, and now do it as a habit.
>>>>>
>>>>> An isolated test-case is definitly the way to go!
>>>>>   
>>>>
>>>>
>>>>
>>>>
>>>> Well I just can't get it any simpler than this. Invalid pointer is 
>>>> still
>>>> present exactly like before. Am I missing something? Brains?
>>>>
>>>> I am using cc++ 1.3.1, gcc 3.3.3 20040412, Fedora Core 2 (Linux). 
>>>> cc++ was
>>>> compiled on this machine. testlistener is the test program.
>>>>
>>>> TCPListener is the one that will create TCPSessionThread per connection
>>>> when there are connections pending.
>>>> TCPSessionThread does nothing at all (and the invalid pointer error
>>>> appears in destructor).
>>>>
>>>> I linked it with -lccgnu2 -ldl  (used also -lpthread, but it is not 
>>>> needed
>>>> really).
>>>>
>>>> Valgrind gives this when connecting the test program and sending 
>>>> some text
>>>> to it: 
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Bug-commoncpp mailing list
>>> Bug-commoncpp@gnu.org
>>> http://lists.gnu.org/mailman/listinfo/bug-commoncpp
>>
>>

--------------080809020404050503040207
Content-Type: text/x-vcard; charset=utf-8;
 name="dyfet.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="dyfet.vcf"

begin:vcard
fn:David Sugar
n:Sugar;David
org:GNU Project
adr:;;23 Olin Drive;Cape May Court House;NJ;08210;USA
email;internet:dyfet@ostel.com
tel;home:1 609 465 5336
tel;cell:1 908 917 6084
x-mozilla-html:FALSE
url:http://www.ostel.com
version:2.1
end:vcard


--------------080809020404050503040207--



From MAILER-DAEMON Sun Feb 13 07:14:56 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1D0Idx-0000Zf-BT
	for mharc-bug-commoncpp@gnu.org; Sun, 13 Feb 2005 07:14:34 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1D0IdB-0000LN-MS
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 07:13:43 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1D0Iaj-0008RI-5D
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 07:11:12 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1D0ITA-0007gh-OQ
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 07:03:21 -0500
Received: from [216.218.222.122] (helo=mail.ostel.com)
	by monty-python.gnu.org with esmtp (Exim 4.34) id 1D0HoA-0007EU-Fi
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 06:20:58 -0500
Received: from [192.168.1.101] (pool-138-89-240-2.atc.east.verizon.net
	[138.89.240.2])
	by mail.ostel.com (Postfix) with ESMTP id 057C72F2864;
	Sun, 13 Feb 2005 03:44:50 -0800 (PST)
Message-ID: <420F3818.4000000@ostel.com>
Date: Sun, 13 Feb 2005 06:20:56 -0500
From: David Sugar <dyfet@ostel.com>
Organization: GNU Project
User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Nick Liebmann <nick@ukmail.org>
References: <420CE18F.5010804@ukmail.org> <420CE725.6010303@ostel.com>
	<420F2C79.4070303@ukmail.org>
In-Reply-To: <420F2C79.4070303@ukmail.org>
Content-Type: multipart/mixed; boundary="------------080905000706040800020003"
Cc: bug-commoncpp@gnu.org
Subject: Re: [Fwd: Re: Haunting free(): invalid pointer 0x8a11604!]
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 13 Feb 2005 12:14:24 -0000

This is a multi-part message in MIME format.
--------------080905000706040800020003
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Ah, I think I might see...both the exit handling for close is called, as 
is the destructor, which includes terminate() that does some other 
stuff?  What does the destructor in your derived object look like?

Nick Liebmann wrote:
> As a penance for trying to sort out this problem with an old version of 
> the library, I have taken a look with the latest version.
> 
> Here are my discoveries:
> 
> As previously stated 'delete this' is called from Thread::close(), and 
> there seems to be no reason to assume anything is wrong with this call. 
> All destructors are called appropriately.
> 
> The problem valgrind reports is that an access is being made to an 
> already deleted chunk of memory, and it seems to be correct...
> 
> After the 'delete this' pthread_exit(NULL) is called, which causes a 
> call to ccxx_thread_destructor, which itself calls 
> ThreadImpl::ThreadDestructor.
> 
> ThreadImpl::ThreadDestructor checks th->priv which is illegal, because 
> th (the thread) has been deleted.
> 
> This is where my knowledge of pthreads becomes flaky, but I reckon this 
> is being called due to the ThreadKey object still having a reference to 
> the thread
> 
> Inserting the line:
> ThreadImpl::_self.setKey(NULL);
> before the call to th->close() in 
> ThreadImpl::ThreadExecHandler(Thread*th) sorts out the problem, however 
> I am not actually sure of  the side effects of this call. Maybe is 
> should be conditional, depending on the detached state of the thread.
> 
> David... its over to you
> 
> Nick
> 
> 
> 
> David Sugar wrote:
> 
>> In older versions of the library you would use "delete this" for 
>> detached threads.  In the current (1.3) releases, you should NEVER do 
>> this.  That final() was appearently leftover from before detach 
>> behavior was changed.  In 1.?2? and definately 1.3, detach deletes the 
>> the thread the object for you after you exit() the thread, and does it 
>> through the virtual destructors via the Thread base class.
>>
>> Nick wrote:
>>
>>>
>>> Ok, your problem is that the TCPSession::final calls delete this when
>>> the thread ends.
>>>
>>> Your choices are
>>>
>>> 1) Dont call tcp->detach(), call start()... the thread will be deleted
>>> automaticall by TCPSession::final
>>> 2) override virtual void final() in TCPSessionThread, to do nothing.
>>>
>>> For the library, TCPSession::final should say if(!isDetached()) 
>>> delete this;
>>>
>>> Rami Saarinen wrote:
>>>
>>>> --- Nick Liebmann <nick@ukmail.org> wrote:
>>>>
>>>>  
>>>>
>>>>> I would also suggest declaring empty virtual destructors for any 
>>>>> inherited classes for which you have no specific
>>>>> need for a destructor. I dont really know why this should be 
>>>>> necessary, but for some reason (at least in the past)
>>>>> I have found this necessary, and now do it as a habit.
>>>>>
>>>>> An isolated test-case is definitly the way to go!
>>>>>   
>>>>
>>>>
>>>>
>>>>
>>>> Well I just can't get it any simpler than this. Invalid pointer is 
>>>> still
>>>> present exactly like before. Am I missing something? Brains?
>>>>
>>>> I am using cc++ 1.3.1, gcc 3.3.3 20040412, Fedora Core 2 (Linux). 
>>>> cc++ was
>>>> compiled on this machine. testlistener is the test program.
>>>>
>>>> TCPListener is the one that will create TCPSessionThread per connection
>>>> when there are connections pending.
>>>> TCPSessionThread does nothing at all (and the invalid pointer error
>>>> appears in destructor).
>>>>
>>>> I linked it with -lccgnu2 -ldl  (used also -lpthread, but it is not 
>>>> needed
>>>> really).
>>>>
>>>> Valgrind gives this when connecting the test program and sending 
>>>> some text
>>>> to it: 
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Bug-commoncpp mailing list
>>> Bug-commoncpp@gnu.org
>>> http://lists.gnu.org/mailman/listinfo/bug-commoncpp
>>
>>

--------------080905000706040800020003
Content-Type: text/x-vcard; charset=utf-8;
 name="dyfet.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="dyfet.vcf"

begin:vcard
fn:David Sugar
n:Sugar;David
org:GNU Project
adr:;;23 Olin Drive;Cape May Court House;NJ;08210;USA
email;internet:dyfet@ostel.com
tel;home:1 609 465 5336
tel;cell:1 908 917 6084
x-mozilla-html:FALSE
url:http://www.ostel.com
version:2.1
end:vcard


--------------080905000706040800020003--



From MAILER-DAEMON Sun Feb 13 13:01:18 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1D0O3a-0004XD-LD
	for mharc-bug-commoncpp@gnu.org; Sun, 13 Feb 2005 13:01:18 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1D0O0b-0003Nc-Ga
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 12:58:14 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1D0O0L-0003Cr-8c
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 12:58:05 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1D0O0E-0003Av-OV
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 12:57:50 -0500
Received: from [195.112.37.194] (helo=jolt.ukmail.org)
	by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168)
	(Exim 4.34) id 1D0Nis-0004yX-Ti
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 12:39:55 -0500
Received: from jolt.ukmail.org ([127.0.0.1] helo=[192.168.123.20])
	by jolt.ukmail.org with esmtp (Exim 3.35 #1 (Debian))
	id 1D0Nip-0000Yl-00; Sun, 13 Feb 2005 17:39:51 +0000
Message-ID: <420F90EB.70004@ukmail.org>
Date: Sun, 13 Feb 2005 17:39:55 +0000
From: Nick Liebmann <nick@ukmail.org>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: David Sugar <dyfet@ostel.com>
References: <420CE18F.5010804@ukmail.org> <420CE725.6010303@ostel.com>
	<420F2C79.4070303@ukmail.org> <420F3818.4000000@ostel.com>
In-Reply-To: <420F3818.4000000@ostel.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cc: bug-commoncpp@gnu.org
Subject: Re: [Fwd: Re: Haunting free(): invalid pointer 0x8a11604!]
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 13 Feb 2005 18:01:15 -0000

Well the destructor in the derived class is empty.

Really the problem is ThreadImpl::ThreadDestructor checks th->priv, from 
an object 'th' which has already been deleted, in the case of a detached 
thread.
Im not really sure of the reasons for the ThreadKey class, but reading 
the pthread documentation for pthread_key_create:

<quote>
An optional destructor function may be associated with each key value. 
At thread exit, if a key value has a non-NULL destructor pointer, and 
the thread has a non-NULL value associated with that key, the function 
pointed to is called with the current associated value as its sole 
argument. The order of destructor calls is unspecified if more than one 
destructor exists for a thread when it exits.
</quote>

So I think either ThreadImpl::ThreadDestructor should delete 'th' if it 
determines its a detached thread, or ThreadImpl::ThreadDestructor should 
not be called for an already deleted thread.


David Sugar wrote:

> Ah, I think I might see...both the exit handling for close is called, 
> as is the destructor, which includes terminate() that does some other 
> stuff?  What does the destructor in your derived object look like?
>
> Nick Liebmann wrote:
>
>> As a penance for trying to sort out this problem with an old version 
>> of the library, I have taken a look with the latest version.
>>
>> Here are my discoveries:
>>
>> As previously stated 'delete this' is called from Thread::close(), 
>> and there seems to be no reason to assume anything is wrong with this 
>> call. All destructors are called appropriately.
>>
>> The problem valgrind reports is that an access is being made to an 
>> already deleted chunk of memory, and it seems to be correct...
>>
>> After the 'delete this' pthread_exit(NULL) is called, which causes a 
>> call to ccxx_thread_destructor, which itself calls 
>> ThreadImpl::ThreadDestructor.
>>
>> ThreadImpl::ThreadDestructor checks th->priv which is illegal, 
>> because th (the thread) has been deleted.
>>
>> This is where my knowledge of pthreads becomes flaky, but I reckon 
>> this is being called due to the ThreadKey object still having a 
>> reference to the thread
>>
>> Inserting the line:
>> ThreadImpl::_self.setKey(NULL);
>> before the call to th->close() in 
>> ThreadImpl::ThreadExecHandler(Thread*th) sorts out the problem, 
>> however I am not actually sure of  the side effects of this call. 
>> Maybe is should be conditional, depending on the detached state of 
>> the thread.
>>
>> David... its over to you
>>
>> Nick
>>
>>
>>
>> David Sugar wrote:
>>
>>> In older versions of the library you would use "delete this" for 
>>> detached threads.  In the current (1.3) releases, you should NEVER 
>>> do this.  That final() was appearently leftover from before detach 
>>> behavior was changed.  In 1.?2? and definately 1.3, detach deletes 
>>> the the thread the object for you after you exit() the thread, and 
>>> does it through the virtual destructors via the Thread base class.
>>>
>>> Nick wrote:
>>>
>>>>
>>>> Ok, your problem is that the TCPSession::final calls delete this when
>>>> the thread ends.
>>>>
>>>> Your choices are
>>>>
>>>> 1) Dont call tcp->detach(), call start()... the thread will be deleted
>>>> automaticall by TCPSession::final
>>>> 2) override virtual void final() in TCPSessionThread, to do nothing.
>>>>
>>>> For the library, TCPSession::final should say if(!isDetached()) 
>>>> delete this;
>>>>
>>>> Rami Saarinen wrote:
>>>>
>>>>> --- Nick Liebmann <nick@ukmail.org> wrote:
>>>>>
>>>>>  
>>>>>
>>>>>> I would also suggest declaring empty virtual destructors for any 
>>>>>> inherited classes for which you have no specific
>>>>>> need for a destructor. I dont really know why this should be 
>>>>>> necessary, but for some reason (at least in the past)
>>>>>> I have found this necessary, and now do it as a habit.
>>>>>>
>>>>>> An isolated test-case is definitly the way to go!
>>>>>>   
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Well I just can't get it any simpler than this. Invalid pointer is 
>>>>> still
>>>>> present exactly like before. Am I missing something? Brains?
>>>>>
>>>>> I am using cc++ 1.3.1, gcc 3.3.3 20040412, Fedora Core 2 (Linux). 
>>>>> cc++ was
>>>>> compiled on this machine. testlistener is the test program.
>>>>>
>>>>> TCPListener is the one that will create TCPSessionThread per 
>>>>> connection
>>>>> when there are connections pending.
>>>>> TCPSessionThread does nothing at all (and the invalid pointer error
>>>>> appears in destructor).
>>>>>
>>>>> I linked it with -lccgnu2 -ldl  (used also -lpthread, but it is 
>>>>> not needed
>>>>> really).
>>>>>
>>>>> Valgrind gives this when connecting the test program and sending 
>>>>> some text
>>>>> to it: 
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Bug-commoncpp mailing list
>>>> Bug-commoncpp@gnu.org
>>>> http://lists.gnu.org/mailman/listinfo/bug-commoncpp
>>>
>>>
>>>



From MAILER-DAEMON Sun Feb 13 15:30:37 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1D0QO4-0002c7-NV
	for mharc-bug-commoncpp@gnu.org; Sun, 13 Feb 2005 15:30:36 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1D0QIv-0001jo-LV
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 15:25:18 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1D0QIh-0001dx-LM
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 15:25:09 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1D0QIb-0001X4-F6
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 15:24:57 -0500
Received: from [216.218.222.122] (helo=mail.ostel.com)
	by monty-python.gnu.org with esmtp (Exim 4.34) id 1D0Prm-0004wq-UU
	for bug-commoncpp@gnu.org; Sun, 13 Feb 2005 14:57:15 -0500
Received: from [192.168.1.101] (pool-138-89-240-2.atc.east.verizon.net
	[138.89.240.2])
	by mail.ostel.com (Postfix) with ESMTP id D2C932F286D;
	Sun, 13 Feb 2005 12:21:09 -0800 (PST)
Message-ID: <420FB118.5030108@ostel.com>
Date: Sun, 13 Feb 2005 14:57:12 -0500
From: David Sugar <dyfet@ostel.com>
Organization: GNU Project
User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Nick Liebmann <nick@ukmail.org>
References: <420CE18F.5010804@ukmail.org> <420CE725.6010303@ostel.com>
	<420F2C79.4070303@ukmail.org> <420F3818.4000000@ostel.com>
	<420F90EB.70004@ukmail.org>
In-Reply-To: <420F90EB.70004@ukmail.org>
Content-Type: multipart/mixed; boundary="------------080508040004090203060407"
Cc: bug-commoncpp@gnu.org
Subject: Re: [Fwd: Re: Haunting free(): invalid pointer 0x8a11604!]
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 13 Feb 2005 20:30:34 -0000

This is a multi-part message in MIME format.
--------------080508040004090203060407
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I think you are absolutely correct that the key should be cleared if 
th->isDetach() is true before calling th->close() and letting it fall 
through the rest of the code.  The threadKey for "self" is also used so 
that arbitrary code can determine and manipulate the actual Thread 
"object" that is associated with the current execution context, rather 
than just the less useful pthread "id".  getThread() uses this.

Nick Liebmann wrote:
> Well the destructor in the derived class is empty.
> 
> Really the problem is ThreadImpl::ThreadDestructor checks th->priv, from 
> an object 'th' which has already been deleted, in the case of a detached 
> thread.
> Im not really sure of the reasons for the ThreadKey class, but reading 
> the pthread documentation for pthread_key_create:
> 
> <quote>
> An optional destructor function may be associated with each key value. 
> At thread exit, if a key value has a non-NULL destructor pointer, and 
> the thread has a non-NULL value associated with that key, the function 
> pointed to is called with the current associated value as its sole 
> argument. The order of destructor calls is unspecified if more than one 
> destructor exists for a thread when it exits.
> </quote>
> 
> So I think either ThreadImpl::ThreadDestructor should delete 'th' if it 
> determines its a detached thread, or ThreadImpl::ThreadDestructor should 
> not be called for an already deleted thread.
> 
> 
> David Sugar wrote:
> 
>> Ah, I think I might see...both the exit handling for close is called, 
>> as is the destructor, which includes terminate() that does some other 
>> stuff?  What does the destructor in your derived object look like?
>>
>> Nick Liebmann wrote:
>>
>>> As a penance for trying to sort out this problem with an old version 
>>> of the library, I have taken a look with the latest version.
>>>
>>> Here are my discoveries:
>>>
>>> As previously stated 'delete this' is called from Thread::close(), 
>>> and there seems to be no reason to assume anything is wrong with this 
>>> call. All destructors are called appropriately.
>>>
>>> The problem valgrind reports is that an access is being made to an 
>>> already deleted chunk of memory, and it seems to be correct...
>>>
>>> After the 'delete this' pthread_exit(NULL) is called, which causes a 
>>> call to ccxx_thread_destructor, which itself calls 
>>> ThreadImpl::ThreadDestructor.
>>>
>>> ThreadImpl::ThreadDestructor checks th->priv which is illegal, 
>>> because th (the thread) has been deleted.
>>>
>>> This is where my knowledge of pthreads becomes flaky, but I reckon 
>>> this is being called due to the ThreadKey object still having a 
>>> reference to the thread
>>>
>>> Inserting the line:
>>> ThreadImpl::_self.setKey(NULL);
>>> before the call to th->close() in 
>>> ThreadImpl::ThreadExecHandler(Thread*th) sorts out the problem, 
>>> however I am not actually sure of  the side effects of this call. 
>>> Maybe is should be conditional, depending on the detached state of 
>>> the thread.
>>>
>>> David... its over to you
>>>
>>> Nick
>>>
>>>
>>>
>>> David Sugar wrote:
>>>
>>>> In older versions of the library you would use "delete this" for 
>>>> detached threads.  In the current (1.3) releases, you should NEVER 
>>>> do this.  That final() was appearently leftover from before detach 
>>>> behavior was changed.  In 1.?2? and definately 1.3, detach deletes 
>>>> the the thread the object for you after you exit() the thread, and 
>>>> does it through the virtual destructors via the Thread base class.
>>>>
>>>> Nick wrote:
>>>>
>>>>>
>>>>> Ok, your problem is that the TCPSession::final calls delete this when
>>>>> the thread ends.
>>>>>
>>>>> Your choices are
>>>>>
>>>>> 1) Dont call tcp->detach(), call start()... the thread will be deleted
>>>>> automaticall by TCPSession::final
>>>>> 2) override virtual void final() in TCPSessionThread, to do nothing.
>>>>>
>>>>> For the library, TCPSession::final should say if(!isDetached()) 
>>>>> delete this;
>>>>>
>>>>> Rami Saarinen wrote:
>>>>>
>>>>>> --- Nick Liebmann <nick@ukmail.org> wrote:
>>>>>>
>>>>>>  
>>>>>>
>>>>>>> I would also suggest declaring empty virtual destructors for any 
>>>>>>> inherited classes for which you have no specific
>>>>>>> need for a destructor. I dont really know why this should be 
>>>>>>> necessary, but for some reason (at least in the past)
>>>>>>> I have found this necessary, and now do it as a habit.
>>>>>>>
>>>>>>> An isolated test-case is definitly the way to go!
>>>>>>>   
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Well I just can't get it any simpler than this. Invalid pointer is 
>>>>>> still
>>>>>> present exactly like before. Am I missing something? Brains?
>>>>>>
>>>>>> I am using cc++ 1.3.1, gcc 3.3.3 20040412, Fedora Core 2 (Linux). 
>>>>>> cc++ was
>>>>>> compiled on this machine. testlistener is the test program.
>>>>>>
>>>>>> TCPListener is the one that will create TCPSessionThread per 
>>>>>> connection
>>>>>> when there are connections pending.
>>>>>> TCPSessionThread does nothing at all (and the invalid pointer error
>>>>>> appears in destructor).
>>>>>>
>>>>>> I linked it with -lccgnu2 -ldl  (used also -lpthread, but it is 
>>>>>> not needed
>>>>>> really).
>>>>>>
>>>>>> Valgrind gives this when connecting the test program and sending 
>>>>>> some text
>>>>>> to it: 
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Bug-commoncpp mailing list
>>>>> Bug-commoncpp@gnu.org
>>>>> http://lists.gnu.org/mailman/listinfo/bug-commoncpp
>>>>
>>>>
>>>>
>>>>

--------------080508040004090203060407
Content-Type: text/x-vcard; charset=utf-8;
 name="dyfet.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="dyfet.vcf"

begin:vcard
fn:David Sugar
n:Sugar;David
org:GNU Project
adr:;;23 Olin Drive;Cape May Court House;NJ;08210;USA
email;internet:dyfet@ostel.com
tel;home:1 609 465 5336
tel;cell:1 908 917 6084
x-mozilla-html:FALSE
url:http://www.ostel.com
version:2.1
end:vcard


--------------080508040004090203060407--



From MAILER-DAEMON Mon Feb 14 07:52:11 2005
Received: from mailman by lists.gnu.org with archive (Exim 4.43)
	id 1D0fhw-0005Vx-MP
	for mharc-bug-commoncpp@gnu.org; Mon, 14 Feb 2005 07:52:09 -0500
Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1D0fhd-0005R9-2H
	for bug-commoncpp@gnu.org; Mon, 14 Feb 2005 07:51:49 -0500
Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1D0fhS-0005OI-Mo
	for bug-commoncpp@gnu.org; Mon, 14 Feb 2005 07:51:41 -0500
Received: from [199.232.76.173] (helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1D0fhS-0005Jt-0n
	for bug-commoncpp@gnu.org; Mon, 14 Feb 2005 07:51:38 -0500
Received: from [206.190.39.193] (helo=web53003.mail.yahoo.com)
	by monty-python.gnu.org with smtp (Exim 4.34) id 1D0fQc-0004lN-Fv
	for bug-commoncpp@gnu.org; Mon, 14 Feb 2005 07:34:14 -0500
Received: (qmail 231 invoked by uid 60001); 14 Feb 2005 12:34:13 -0000
Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com;
	b=APxSu9NbIE30/kOZAbTbvQC2D1mmNa/edrgUZNYTszTHPW6NONSmRiojjYOvqXobbcS4x17IwHWl7rA8j6s2mGIgFmQsKgqVzMzOIE27T6kqzwhVRWFNKyoCAXSLYAO21zNyFr5B3cNf5GJp731LqObGdeaLZMDKQnc3D79TE3o=
	; 
Message-ID: <20050214123413.229.qmail@web53003.mail.yahoo.com>
Received: from [153.1.60.204] by web53003.mail.yahoo.com via HTTP;
	Mon, 14 Feb 2005 04:34:13 PST
Date: Mon, 14 Feb 2005 04:34:13 -0800 (PST)
From: Rami Saarinen <rs55862@yahoo.com>
To: Nick Liebmann <nick.liebmann@vistek.tv>, Common C++ <bug-commoncpp@gnu.org>
In-Reply-To: <420DC856.10208@vistek.tv>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Cc: 
Subject: Re: Haunting free(): invalid pointer 0x8a11604!
X-BeenThere: bug-commoncpp@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Bug reports for Common C++ <bug-commoncpp.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-commoncpp>
List-Post: <mailto:bug-commoncpp@gnu.org>
List-Help: <mailto:bug-commoncpp-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-commoncpp>,
	<mailto:bug-commoncpp-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 14 Feb 2005 12:51:52 -0000


Actually the problem was also present with older versions. Not 1.0.9
thought, but if I recall right the invalid pointer started to appear in
1.1.0 or something like that. That's one of the reasons why I did not
update earlier.

Furthermore doing the solution 2 does get rid of the invalid pointer
error.  But I just found out that 1.3.4 is out, so I'll give it a try
first. 

Thanks Nick and David!

--
Rami Saarinen

   


--- Nick Liebmann <nick.liebmann@vistek.tv> wrote:

> I discovered I was using a older version of commonc++, so I dont think 
> this is your problem.
> I am sure David will come up with something
> 
> Nick
> 
> Rami Saarinen wrote:
> 
> >--- Nick Liebmann <Nick.Liebmann@vistek.tv> wrote:
> >
> >  
> >
> >>Ok, your problem is that the TCPSession::final calls delete this when 
> >>the thread ends.
> >>
> >>Your choices are
> >>
> >>1) Dont call tcp->detach(), call start()... the thread will be deleted
> 
> >>automaticall by TCPSession::final
> >>2) override virtual void final() in TCPSessionThread, to do nothing.
> >>
> >>For the library, TCPSession::final should say if(!isDetached()) delete
> >>this;
> >>    
> >>
> >
> >Thanks Nick! I'll check this out on monday. 
> >
> >
> >--
> >Rami Saarinen
> >
> >
> >
> >		
> >__________________________________ 
> >Do you Yahoo!? 
> >All your favorites on one personal page – Try My Yahoo!
> >http://my.yahoo.com 
> >
> >
> >  
> >
> 
> 



		
__________________________________ 
Do you Yahoo!? 
Take Yahoo! Mail with you! Get it on your mobile phone. 
http://mobile.yahoo.com/maildemo 



