Re: Interesting coding idea
From: Dave Vandervies (dj3vande_at_csclub.uwaterloo.ca)
Date: 10/25/04
- Next message: Gregory L. Hansen: "Re: Free-trade and Offshoring of jobs argument"
- Previous message: Paul Lutus: "Re: C to Java Byte Code"
- In reply to: boa: "Re: Interesting coding idea"
- Next in thread: William Ahern: "Re: Interesting coding idea"
- Reply: William Ahern: "Re: Interesting coding idea"
- Reply: boa: "Re: Interesting coding idea"
- Reply: Thad Smith: "Re: Interesting coding idea"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 25 Oct 2004 18:54:10 +0000 (UTC)
In article <b%afd.3012$HA5.353696@juliett.dax.net>,
boa <root@localhost.com> wrote:
>Dave Vandervies wrote:
>> Why not build a DeathStation simulator?
>>
>> Create a VM that allows aggressive testing for bad (especially not-
>> well-defined) code, and a compiler targeting it that optimizes for
>> checkability rather than performance or size.
[Snip a few ideas]
>> Other thoughts?
>It exists already and is called valgrind ;-)
That would be this valgrind (first hit on Google)?
"Valgrind, an open-source memory debugger for x86-linux"
How many of these will valgrind catch?
--------
/*Mentioned in my post - have the VM be aware of sequence points so it
can catch this
*/
i=i++;
--------
int *foo(int *dummy)
{
int i;
return &i;
}
int bar(int *p)
{
int dummy=42;
return *p;
}
/*In a function somewhere*/
/*Ideally, we want to warn here, when a no-longer-valid pointer is stored
in a variable (or, better, immediately on return from foo when the
storage the pointer points at goes away)
*/
p=foo(&i);
/*p is an invalid pointer; typical stack-using implementations will
have it pointing at the dummy int in bar()
*/
i=bar(p);
--------
char buf[10];
char *str=some_string_pointer;
buf[0]='\0';
/*We want to warn about this (claimed buffer size larger than actual
destination buffer) even if str fits into buf
*/
strncat(buf,str,20);
--------
Without knowing anything other than that it's a memory debugger, I'd give
part marks for the third one (no warning if the buffer doesn't overflow)
and a small chance at catching the second one.
Of course, it looks like it won't even get there if I try to run it on
a Mac.
So, quite obviously not what I was thinking of.
dave
-- Dave Vandervies dj3vande@csclub.uwaterloo.ca I suspect all the things you mention are covered within the first 150 pages of [K&R2]. At that point, most books on programming are still showing you how to use the GUI editor. --Richard Heathfield in comp.lang.c
- Next message: Gregory L. Hansen: "Re: Free-trade and Offshoring of jobs argument"
- Previous message: Paul Lutus: "Re: C to Java Byte Code"
- In reply to: boa: "Re: Interesting coding idea"
- Next in thread: William Ahern: "Re: Interesting coding idea"
- Reply: William Ahern: "Re: Interesting coding idea"
- Reply: boa: "Re: Interesting coding idea"
- Reply: Thad Smith: "Re: Interesting coding idea"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|