null references can be unsafe [was Re: Coverity tool]

Leandro Lucarella llucax at gmail.com
Wed Feb 10 13:50:36 PST 2010


Walter Bright, el 10 de febrero a las 11:33 me escribiste:
> retard wrote:
> >Tue, 09 Feb 2010 18:49:31 -0800, Walter Bright wrote:
> >
> >>D has moved a lot towards supplying by default a lot of what Coverity
> >>claims to do. By making such an expensive tool irrelevant for D, we can
> >>make D much more cost effective.
> >
> >D doesn't provide non-nullable types
> 
> Yes, there have been a couple long threads about that. Dereferencing
> a null pointer is a bug, but not a security/safety issue.

What about 3677?

Quote:
--------------------------------
This supposedly "safe" program under Mac OS X 10.6 doesn't give any error
neither at compile time nor at runtime, yet it isn't memory-safe at all as
it corrupts some part of the memory space.

struct S {
    uint[100000] a;
    uint b;
}

S* s = null;

@safe void main() {
    s.b = 1;
}

This happen because the offset for member "b" is very far, allowing it to
falls on another memory page which happen to exists.
--------------------------------

http://d.puremagic.com/issues/show_bug.cgi?id=3677

It's a strange case, I know...

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------



More information about the Digitalmars-d mailing list