[erlang-bugs] io:format() call makes emulator hang

Scott Lystig Fritchie <>
Thu May 29 21:56:41 CEST 2008


Vitaly Barinov <> wrote:

vb> I have discovered very annoying problem (which I would dare call a
vb> bug), present in R12B and several earlier releases on Windows: An
vb> attempt to output large enough string makes Erlang hang.

We've encountered this same problem with real/production data, not just
test data that lists:seq(1, 100000) generates.  In our case, it's been
very large binaries (multi-megabyte) with non-printable bytes in them,
so each byte is formatted as decimal numbers.  An example of
lists:seq(255, 100000) would consume even more memory.  :-)

At the moment, all I'm aware of is the same solution as the "Doctor, it
hurts when I do this" problem.  In our case, we combed through our
custom error handler and either use "~P" formatting to limit formatting
depth, or use size(term_to_binary(SuspiciousTerm)) to figure out if
formatting is even worthwhile: term_to_binary() consumes RAM also, but
not nearly as much as io:format or io_lib:format will.

I agree with the VM's runtime policy of crashing when it can't allocate
memory from the OS ... but it is quite surprising (and can be difficult
to fix) when that same crash robs you of the VM's diagnostic tools.

Any thoughts from The OTP Folks?

-Scott



More information about the erlang-bugs mailing list