Subject: alloca() question
To: None <current-users@NetBSD.ORG>
From: Matthieu Herrb <matthieu@laas.fr>
List: current-users
Date: 07/11/1996 22:57:42
Hi,
I recently found that, at least on the 386, alloca() doesn't return
NULL when the stack limit is reached. Is it a bug or a feature ?
If it's a feature, the alloca() man page is false.
The follwing (ugly) program seg faults to demonstrate it:
#include <stdio.h>
#include <stdlib.h>
main()
{
char *p;
int i = 0;
while (1) {
p = alloca(1024);
if (p == NULL) {
printf("stop: i = %d\n", i);
exit(0);
}
i++;
printf("%d\n", i);
*p = 0;
}
}
Matthieu