Skip to content

Instantly share code, notes, and snippets.

@itsbth
Created January 9, 2012 17:26
Show Gist options
  • Select an option

  • Save itsbth/1584004 to your computer and use it in GitHub Desktop.

Select an option

Save itsbth/1584004 to your computer and use it in GitHub Desktop.
Uploaded by UploadToGist for Sublime Text 2
#include <malloc.h>
#include <alloca.h>
#include <stdio.h>
#include <sys/resource.h>
size_t sizzle;
void recurse(int i) {
char *foo = alloca(sizzle);
foo[sizzle - 1] = 0;
fprintf(stderr, "%x", (unsigned int)foo);
printf("%d\n", i);
recurse(i + 1);
}
int main() {
struct rlimit *rlim = malloc(sizeof (struct rlimit));
if (getrlimit(RLIMIT_STACK, rlim) == 0) {
sizzle = rlim->rlim_max;
} else {
printf("ERROR");
return 1;
}
recurse(0);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment