Re: gdb not catching out-of-bounds pointer
- From: Ben Bacarisse <ben.usenet@xxxxxxxxx>
- Date: Wed, 17 Dec 2008 13:10:03 +0000
Rainer Weikusat <rweikusat@xxxxxxxxxxx> writes:
Ben Bacarisse <ben.usenet@xxxxxxxxx> writes:<snip>
Techniques that break ABI compatibility would be out, yes, but code
that, for example, accesses one array from a pointer to another is
already broken to some extent.
Such code is not written in strictly conforming C. It is nevertheless
extremly common whenever actual memory management is involved. This
implies that any malloc implementation not written in assembly
would then be 'broken to some extent', the same being true for all
operating systems kernels and parts thereof, specifically, device
drivers, as well. And this isn't even a real escape route because
combining object code files generated from different source language
is also not defined by the C-standard, IOW: writing code in anything
but assembly is 'broken to some extent'.
You obviously don't like my choice of words and I agree that is was
not ideal. It might have been better to say something like
"worryingly familiar with the implementation". Code inside malloc
*is* the implementation, so any degree of familiarity is fine --
provided the library writer knows what the compiler writer guarantees
about undefined code. In other words, how much you worry about this
familiarity depends on who you are and what sort of code you are
writing.
Writing a portable allocator would require more strict adherence to
the standard unless a particular compiler (with extra assurances)
could be assumed. But not all undefined behaviour is equal. For
example, I would worry much less about comparing void *s (with >, >=
etc.) that don't point into the same array than I would about the sort
of pointer aliasing issue that started this sub-thread. I don't know
of any compiler that makes dangerous assumptions about the former, but
I do know some that do about the latter.
--
Ben.
.
- Follow-Ups:
- Re: gdb not catching out-of-bounds pointer
- From: Måns Rullgård
- Re: gdb not catching out-of-bounds pointer
- From: Rainer Weikusat
- Re: gdb not catching out-of-bounds pointer
- References:
- gdb not catching out-of-bounds pointer
- From: Tomás Ó hÉilidhe
- Re: gdb not catching out-of-bounds pointer
- From: Nate Eldredge
- Re: gdb not catching out-of-bounds pointer
- From: Tomás Ó hÉilidhe
- Re: gdb not catching out-of-bounds pointer
- From: David Schwartz
- Re: gdb not catching out-of-bounds pointer
- From: Måns Rullgård
- Re: gdb not catching out-of-bounds pointer
- From: David Schwartz
- Re: gdb not catching out-of-bounds pointer
- From: Måns Rullgård
- Re: gdb not catching out-of-bounds pointer
- From: David Schwartz
- Re: gdb not catching out-of-bounds pointer
- From: Ben Bacarisse
- Re: gdb not catching out-of-bounds pointer
- From: David Schwartz
- Re: gdb not catching out-of-bounds pointer
- From: Ben Bacarisse
- Re: gdb not catching out-of-bounds pointer
- From: Rainer Weikusat
- gdb not catching out-of-bounds pointer
- Prev by Date: Re: gdb not catching out-of-bounds pointer
- Next by Date: Re: gdb not catching out-of-bounds pointer
- Previous by thread: Re: gdb not catching out-of-bounds pointer
- Next by thread: Re: gdb not catching out-of-bounds pointer
- Index(es):
Relevant Pages
|