Subject: malloc problem
To: None <tech-userlevel@netbsd.org>
From: Emmanuel Dreyfus <Emmanuel.Dreyfus@espci.fr>
List: tech-userlevel
Date: 11/16/2001 15:39:13
Hi!

The following program crashes on NetBSD/i386-1.5.2. I expected malloc() to
return NULL and setting errno to ENOMEM instead of getting a crash. Is there
any explanation for this, or is it a bug?

#include <stdio.h>
#include <stdlib.h>

int
main (void)
{
        int m = 0xbfbfdc50;
        char *brokenbuf;
        
        printf ("m = 0x%x\n", m);
        printf ("I'm still alive\n");

        brokenbuf = malloc(m);

        printf ("I cannot stand this\n");

        return 0;
}

-- 
Emmanuel Dreyfus                             Emmanuel.Dreyfus@espci.fr
Cette signature vous est fournie telle quelle, sans aucune garantie de 
fonctionnement. En la lisant, vous acceptez les préjudices matériels, 
physiques, et moraux qu'elle pourrait causer.