Am 24.04.23 um 16:24 schrieb Frederick Virchanza Gotham:
> On Monday, April 24, 2023 at 8:06:59 AM UTC+1, Öö Tiib wrote:
>>
>> Note that whatever it invokes may not throw ... otherwise everything ends in spectacular manner.
>
>
> I've written it to support exception handling:
>
>
https://godbolt.org/z/M9544Meqq
I remember doing a similar hack back in the days on MSDOS, where stack
space really was an issue - the required amount was embedded into the
EXE file format and fixed at link time.
>
> As far as I know, on Linux the max stack size is 100 MB. With this technique you can have gigabytes of stack. More importantly, you can temporarily de-allocate memory, and then allocate the stack, then de-allocate the stack, then re-allocate the original memory.
On Linux, you can have unlimited stack space. I once used up all the
stack space by a recursive algorithm, getting the system down via disk
thrashing. For these reasons, most Linux distros set the limits to some
reasonable size:
root@h2015100:~# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 4125377
max locked memory (kbytes, -l) 65536
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 62987
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
But you can use "ulimit" to increase that as you wish:
root@h2015100:~# ulimit -s 2000000
root@h2015100:~# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 4125377
max locked memory (kbytes, -l) 65536
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 2000000
cpu time (seconds, -t) unlimited
max user processes (-u) 62987
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
root@h2015100:~#
Christian