[erlang-bugs] VM crash when using a matched binary as function

Loïc Hoguin essen@REDACTED
Wed Feb 5 16:04:51 CET 2014


Hello,

The following code crashes the VM:


-module(crashing).
-compile(export_all).

crash(Bin) ->
	crash(Bin, <<>>).

crash(<<>>, Acc) ->
	Acc;
crash(<< C, Rest/bits >>, Acc) ->
	%% There is no crash if we print the variable Rest before using it.
	%% Uncomment to see the difference.
	% io:format("~p~n", [Rest]),
	Rest(<< Acc/binary, C >>).


The following happens:


% erlc crashing.erl
% erl
Erlang/OTP 17 [RELEASE CANDIDATE 1] [erts-6.0] [source-8d71ab4] [64-bit] 
[smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V6.0  (abort with ^G)
1> crashing:crash(<<"abc">>).
size_object: matchstate term not allowedzsh: abort (core dumped)  erl


This is today's master, but it also happens at least with R16B02.

While the code is clearly nonsense when you read it, it would be better 
if it wouldn't crash anymore in R17.

-- 
Loïc Hoguin
http://ninenines.eu



More information about the erlang-bugs mailing list