public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Memory corruption problem
@ 2002-10-24 12:29 ducharme
  2002-10-24 13:26 ` Sam Halliday
  0 siblings, 1 reply; 2+ messages in thread
From: ducharme @ 2002-10-24 12:29 UTC (permalink / raw)
  To: gcc-help

[-- Attachment #1: Type: text/plain, Size: 610 bytes --]

Hello,

I am using gcc 2.95 on Sun SPARC Solaris 8.

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.

I was wondering if there was some library routines which
could help me locate where I am overwriting unaloocated
memory.

Sincerely,

Michel Ducharme.

[-- Attachment #2: Card for <ducharme@uqo.ca> --]
[-- Type: text/x-vcard, Size: 322 bytes --]

begin:vcard
n:Ducharme;Michel
fn:Michel Ducharme
tel;fax:(819) 773-1699
tel;work:(819) 595-3900 poste 1615
url:http://w3.uqo.ca/
org:Université du Québec en Outaouais;Service de l'informatique
adr:;;101, rue St-Jean Bosco;Hull;Québec;J8Y 3G5;Canada
version:2.1
email;internet:michel.ducharme@uqo.ca
end:vcard


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Memory corruption problem
  2002-10-24 12:29 Memory corruption problem ducharme
@ 2002-10-24 13:26 ` Sam Halliday
  0 siblings, 0 replies; 2+ messages in thread
From: Sam Halliday @ 2002-10-24 13:26 UTC (permalink / raw)
  To: gcc-help

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 <your program name>'
export MPRFI='cat > badmem.log'
mpr -f -l <your program name> < 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-10-24 20:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-24 12:29 Memory corruption problem ducharme
2002-10-24 13:26 ` Sam Halliday

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).