News for hackers. Stuff that matters.
Re:TinyVM: A lightweight, fast virtual machine in < 500 l... by kragen on Monday July 04, 2011 @04:56PM (#2727852)
> Really? How would dereferencing a NULL pointer cause "some really nasty crashes"?

See "Dowd's Inhuman Flash Exploit":

http://evernote.com/pub/petro/random#b=1988c9d5-c0ab-466e-9c...

Maybe see also the various posts on the clang blog about undefined behavior.

> The best and cleanest solution is to crash.

Then write code to crash, you bozo, don't hope the runtime will do it for you. We're not talking about a fucking missile guidance system here:

    void *xmalloc(size_t s) {
            void *rv = malloc(s);
            if (!rv) abort();
            return rv;
    }
xrealloc() is only slightly longer.

Writing and using these functions is not "error prone" or "hard to maintain", and does not "destroy readability". It adds a single letter to each of these function calls and avoids writing any more error-handling code.

That's a completely reasonable solution, but it's not the one you took. It's not the path of least resistance, but when you're programming in C, writing robust code is very rarely the path of least resistance.

With regard to your nonsense about "will only ever happen on 32-bit OSes", I run programs under VM size ulimits every day. This prevents them from forcing the system into swap and becoming unresponsive, by causing their allocations to fail. Some of them (e.g. less) usually handle running out of memory quite well. I happen to be using 32-bit OSes, but that's irrelevant; I would do the same thing on 64-bit OSes.

There are no comments on this comment yet.