Skip to content

Instantly share code, notes, and snippets.

@Costava
Created July 14, 2021 03:26
Show Gist options
  • Save Costava/fc06138152bc54d0ba55bafd8f3a37f0 to your computer and use it in GitHub Desktop.
Save Costava/fc06138152bc54d0ba55bafd8f3a37f0 to your computer and use it in GitHub Desktop.
/*
* File: stacksize.c
* Author: Costava
*
* Example compilation:
* gcc stacksize.c -o stacksize -std=c89 -Wall -Wextra -Wconversion
*/
#include <stdint.h>
#include <stdio.h>
/*
* Segfaults with 9000000
* Works with 8000000
* Because stack size is 8192 KiB
* Get stack size from `ulimit -s`
*/
#define LEN 8000000
int main(void) {
uint8_t foo[LEN];
size_t i;
for (i = 0; i < LEN; i += 1) {
foo[i] = (uint8_t)i;
}
printf("%d\n", foo[1234567]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment