Skip to content

Instantly share code, notes, and snippets.

@Kakadu
Created November 14, 2021 09:22
Show Gist options
  • Save Kakadu/78ab250cdf83e56b207a3e97dafd2c97 to your computer and use it in GitHub Desktop.
Save Kakadu/78ab250cdf83e56b207a3e97dafd2c97 to your computer and use it in GitHub Desktop.
Stack overflow
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10116 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10173 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10192 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10230 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10252 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10271 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10290 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10328 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10366 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10385 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10404 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10423 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10519 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10538 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10619 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10638 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10677 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10715 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10778 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10797 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
depth = 523664, size_tail = 523664
depth = 523665, size_tail = 523665
➜ cps git:(master) ✗ dune exec ./cps_main.exe
Entering directory '/media/work/asp/fp2020/materials/code'
Entering directory '/media/work/asp/fp2020/materials/code'
[1] 10892 segmentation fault dune exec ./cps_main.exe
➜ cps git:(master) ✗ cat cps_main.ml| head -n 26
let n2 =
match Sys.backend_type with
| Sys.Bytecode -> 261_793 + 283
| Native -> (261_793 * 2) + 78
| _ -> failwith "not implemented"
module L = struct
let rec make depth =
if depth <= 0 then []
else
let r = make (depth - 1) in
1 :: r
let size = List.length
let _ =
(* Gives stack overflow *)
let wrap n =
Format.printf "depth = %d, size_tail = %s\n%!" n
( try string_of_int @@ size (make n)
with Stack_overflow -> "<stack overflow>" ) in
wrap n2;
wrap (n2 + 1)
end
let _ = exit 0
➜ cps git:(master) ✗
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment