use v5.24; use warnings; # tested with: # ulimit -s: 8192 kB # Perl 5.38.2 # Debian 12.6 running in Docker container # watch stack size with: watch -n 1 "pidstat -s -l -C 'perl test_stack' | grep -v pidstat" for my $Count ( 1 .. 10_000_000 ) { sleep 1 unless $Count % 1_000; binmode STDOUT, ':encoding(UTF-8)'; # core dump after 34924 iterations #binmode STDERR, ':encoding(UTF-8)'; # core dump after 261923 #binmode STDOUT; # stack used size stays at 20 kB say "Count: $Count"; }