Skip to content

Instantly share code, notes, and snippets.

@nox

nox/erlc.log Secret

Last active December 16, 2015 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nox/2e33fe9a85e035caadda to your computer and use it in GitHub Desktop.
Save nox/2e33fe9a85e035caadda to your computer and use it in GitHub Desktop.
This module makes beam_receive crash.
$ erlc -W +debug_info t.core
Function: request/2
t.core:none: internal error in beam_receive;
crash reason: {{case_clause,
{'EXIT',
{{case_clause,[{y,1},{y,0}]},
[{beam_receive,opt_recv,5,
[{file,"beam_receive.erl"},{line,154}]},
{beam_receive,opt,3,
[{file,"beam_receive.erl"},{line,109}]},
{beam_receive,function,1,
[{file,"beam_receive.erl"},{line,79}]},
{beam_receive,'-module/2-lc$^0/1-0-',1,
[{file,"beam_receive.erl"},{line,68}]},
{beam_receive,module,2,
[{file,"beam_receive.erl"},{line,68}]},
{compile,'-select_passes/2-anonymous-2-',2,
[{file,"compile.erl"},{line,476}]},
{compile,'-internal_comp/4-anonymous-1-',2,
[{file,"compile.erl"},{line,276}]},
{compile,fold_comp,3,
[{file,"compile.erl"},{line,294}]}]}}},
[{compile,'-select_passes/2-anonymous-2-',2,
[{file,"compile.erl"},{line,476}]},
{compile,'-internal_comp/4-anonymous-1-',2,
[{file,"compile.erl"},{line,276}]},
{compile,fold_comp,3,[{file,"compile.erl"},{line,294}]},
{compile,internal_comp,4,[{file,"compile.erl"},{line,278}]},
{compile,'-do_compile/2-anonymous-0-',2,
[{file,"compile.erl"},{line,152}]}]}
{module, t}. %% version = 0
{exports, [{module_info,0},{module_info,1},{request,2}]}.
{attributes, []}.
{labels, 19}.
{function, request, 2, 2}.
{label,1}.
{line,[]}.
{func_info,{atom,t},{atom,request},2}.
{label,2}.
{allocate_zero,2,2}.
{test_heap,3,2}.
{move,{x,0},{y,1}}.
{put_tuple,2,{x,2}}.
{put,{atom,data}}.
{put,{x,1}}.
{move,{x,2},{y,0}}.
{line,[]}.
{call_ext,0,{extfunc,erlang,make_ref,0}}. % Ref in [x0]
{test_heap,4,1}.
{put_tuple,3,{x,1}}.
{put,{atom,request}}.
{put,{x,0}}.
{put,{y,0}}.
{move,{x,0},{y,0}}. % Ref in [x0,y0]
{move,{y,1},{x,0}}. % Ref in [y0]
{kill,{y,1}}.
{line,[]}.
send.
{move,{y,0},{x,0}}. % Ref in [x0,y0]
{move,{x,0},{y,1}}. % Ref in [x0,y0,y1]
{line,[]}.
{label,5}.
{loop_rec,{f,6},{x,0}}. % Ref in [y0,y1]
{test,is_tuple,{f,8},[{x,0}]}.
{test,test_arity,{f,8},[{x,0},2]}.
{get_tuple_element,{x,0},0,{x,1}}.
{get_tuple_element,{x,0},1,{x,2}}.
{test,is_eq_exact,{f,8},[{x,1},{atom,reply}]}.
{test,is_eq_exact,{f,8},[{x,2},{y,1}]}.
remove_message.
{move,{atom,ok},{x,0}}.
{deallocate,2}.
return.
{label,8}.
{loop_rec_end,{f,5}}.
{label,6}.
{wait,{f,5}}.
{label,7}.
{label,4}.
{label,3}.
if_end.
{function, module_info, 0, 12}.
{label,11}.
{line,[]}.
{func_info,{atom,t},{atom,module_info},0}.
{label,12}.
{move,{atom,t},{x,0}}.
{line,[]}.
{call_ext_only,1,{extfunc,erlang,get_module_info,1}}.
{label,14}.
{label,13}.
if_end.
{function, module_info, 1, 16}.
{label,15}.
{line,[]}.
{func_info,{atom,t},{atom,module_info},1}.
{label,16}.
{move,{x,0},{x,1}}.
{move,{atom,t},{x,0}}.
{line,[]}.
{call_ext_only,2,{extfunc,erlang,get_module_info,2}}.
{label,18}.
{label,17}.
if_end.
module 't' ['module_info'/0,
'module_info'/1,
'request'/2]
attributes []
'request'/2 =
%% Line 4
fun (_cor1,_cor0) ->
let <_fol1> = {%% Line 5
'data',_cor0}
in let <R> =
%% Line 11
call 'erlang':'make_ref'
()
in let <Ref> =
do %% Line 12
call 'erlang':'!'
(_cor1, {'request',R,_fol1})
%% Line 13
R
in %% Line 16
receive
%% Line 17
<{'reply',_cor2}>
when call 'erlang':'=:='
(_cor2,
Ref) ->
%% Line 18
'ok'
after 'infinity' ->
'true'
'module_info'/0 =
fun () ->
call 'erlang':'get_module_info'
('t')
'module_info'/1 =
fun (_cor0) ->
call 'erlang':'get_module_info'
('t', _cor0)
end
-module(t).
-export([request/2]).
request(File, Data) ->
Ref = do_request(File, {data, Data}),
wait_reply(Ref).
-compile({inline,[do_request/2,wait_reply/1]}).
do_request(Io, Request) ->
R = make_ref(),
Io ! {request,R,Request},
R.
wait_reply(Reference) ->
receive
{reply,Reference} ->
ok
end.
module 't_inlined_by_hand' ['module_info'/0,
'module_info'/1,
'request'/2]
attributes []
'request'/2 =
%% Line 4
fun (_cor1,_cor0) ->
let <Request> = {%% Line 5
'data',_cor0}
in let <R> =
%% Line 6
call 'erlang':'make_ref'
()
in do %% Line 7
call 'erlang':'!'
(_cor1, {'request',R,Request})
%% Line 9
receive
%% Line 10
<{'reply',_cor7}>
when call 'erlang':'=:='
(_cor7,
R) ->
%% Line 11
'ok'
after 'infinity' ->
'true'
'module_info'/0 =
fun () ->
call 'erlang':'get_module_info'
('t')
'module_info'/1 =
fun (_cor0) ->
call 'erlang':'get_module_info'
('t', _cor0)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment