Created
July 14, 2021 03:26
-
-
Save Costava/fc06138152bc54d0ba55bafd8f3a37f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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