From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10029 invoked by alias); 24 Oct 2002 20:26:50 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 9826 invoked from network); 24 Oct 2002 20:26:46 -0000 Received: from unknown (HELO pc-80-195-35-109-ed.blueyonder.co.uk) (80.195.35.109) by sources.redhat.com with SMTP; 24 Oct 2002 20:26:46 -0000 Received: from pc-80-195-35-109-ed.blueyonder.co.uk (localhost.localdomain [127.0.0.1]) by pc-80-195-35-109-ed.blueyonder.co.uk (8.12.6/8.12.6) with ESMTP id g9OKQjI4005068 for ; Thu, 24 Oct 2002 21:26:45 +0100 Received: (from samuel@localhost) by pc-80-195-35-109-ed.blueyonder.co.uk (8.12.6/8.12.6/Submit) id g9OKQj7j005067; Thu, 24 Oct 2002 21:26:45 +0100 Date: Thu, 24 Oct 2002 13:26:00 -0000 From: Sam Halliday To: gcc-help@gcc.gnu.org Subject: Re: Memory corruption problem Message-Id: <20021024212645.40e109be.fommil@yahoo.ie> In-Reply-To: References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SW-Source: 2002-10/txt/msg00310.txt.bz2 On Thu, 24 Oct 2002 15:29:47 -0400 ducharme@uqo.ca wrote: > I am using gcc 2.95 on Sun SPARC Solaris 8. poor you... > I am experimenting a memory corruption problem in a C++ > program. I have put in some traces and I know exactly > where the memory corrruption happens but, at that point, > I have most likely already overwritten some memory. > The program terminates normally but outputs partially > corrupted data. > I have been through my source code but I cannot seem to > find where I could be writing to some unallocated memory. have you broke your algos into tiny standalone programs and seen if any of them show the effects individually? > I was wondering if there was some library routines which > could help me locate where I am overwriting unaloocated > memory. there certainly are... try Taj Khattra's mpr package at ftp://metalab.unc.edu/pub/Linux/devel/lang/c/mpr-2.2.tar.gz read the docs about it, essentially you build this static lib and build with it (making sure to use -g), set some environment variables and run your program. the output when you run your program will gove you no info at all.. but use the output with the mprlk program in the same package... a shortcut would be export MPRPC='mprpc ' export MPRFI='cat > badmem.log' mpr -f -l < badmem.log | mprlk i've never used it myself, but a programming book i once read spoke well of its uses... or you can use electric fence at ftp://metalab.unc.edu/pub/Linux/devel/lang/c/ElectricFence-2.0.5.tar.gz or use a lint brush like splint http://www.splint.org/ i have only ever used splint.. which is nice the first few time syou run it and learn a bit, but annoying afterwards.... im afraid its a lot of RTFM form there as i cant help any more than this... cheers, Sam -- If you aren't rich you should always look useful. -- Louis-Ferdinand Celine