HigherOrderCO/hvm-64

OOM in a program that shouldn't grow

Closed this issue · 0 comments

From Discord.
I would think this is a tail-recursive program that can run with any N, just growing the CPU time but not any memory usage:

Main n = (Sum (PowOfTwo n))

PowOfTwo n = (PowOfTwoHelp 1 n)
PowOfTwoHelp acc 0 = acc
PowOfTwoHelp acc e = (* 2 (PowOfTwoHelp acc (- e 1)))

Sum n = (SumHelp 0 n)
SumHelp acc 0 = acc
SumHelp acc n = (SumHelp (+ acc 1) (- n 1))

But it fails around 2^28

$ hvml run -m 32G -O all -s count-sequential.hvml 28

with

OOM
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::option::expect_failed
   3: hvmc::run::allocator::Allocator::alloc
   4: <hvmc::run::def::InterpretedDef as hvmc::run::def::AsDef>::call