[erlang-patches] [erlang-bugs] Unused variable causing v3_kernel crash
Anthony Ramine
n.oxyde@REDACTED
Sun Feb 3 03:28:47 CET 2013
I may have a fix for this:
git fetch https://github.com/nox/otp.git fix-seq-opt
https://github.com/nox/otp/compare/erlang:master...fix-seq-opt
https://github.com/nox/otp/compare/erlang:master...fix-seq-opt.patch
Your bug seems to come from the Core Erlang to Kernel Erlang pass not coping with
multiple values into sequences' arguments, that is expressions which values aren't
used.
My branch adds a new check to core_lint to detect that kind of invalid code and
fixes sys_core_fold so that it doesn't generate it anymore when optimizing away
unused values.
To check that this is indeed sys_core_fold's optimizations that makes the
compilation fail, do:
erlc +no_copt sample.erl
To enable the Core Erlang linting pass, do:
erlc +clint sample.erl
Regards,
--
Anthony Ramine
Le 2 févr. 2013 à 21:42, José Valim a écrit :
> Hello everyone,
>
> The following module fails to compile using both R15B03-01 and R16A:
>
> -module(sample).
> -export([hello/1]).
>
> hello(X) ->
> case do_something(X) of
> false ->
> A = false;
> Res ->
> { A, B } = Res,
> do_something(A),
> do_something(B)
> end,
> ThisShouldNotFail = A,
> ok.
>
> do_something(X) ->
> external:do_something(X).
>
> With the following exception:
>
> crash reason: {function_clause,
> [{v3_kernel,lit_vars,
> [{ivalues,
> [11,{file,"sample.erl"}],
> [{k_var,[],ker4},{k_atom,[],ok}]}],
> [{file,"v3_kernel.erl"},{line,1749}]},
> {v3_kernel,uexpr,3,[{file,"v3_kernel.erl"},{line,1628}]},
> {v3_kernel,ubody,3,[{file,"v3_kernel.erl"},{line,1408}]},
> {v3_kernel,ubody,3,[{file,"v3_kernel.erl"},{line,1409}]},
> {v3_kernel,umatch,3,[{file,"v3_kernel.erl"},{line,1716}]},
> {v3_kernel,'-umatch_list/3-anonymous-0-',3,
> [{file,"v3_kernel.erl"},{line,1735}]},
> {v3_kernel,umatch,3,[{file,"v3_kernel.erl"},{line,1711}]},
> {v3_kernel,'-umatch_list/3-anonymous-0-',3,
> [{file,"v3_kernel.erl"},{line,1735}]}]}
>
> The code and exceptions are also available here: https://gist.github.com/7bd4eea30cd187e68caa
>
> Removing the `ThisShouldNotFail` assignment makes it work correctly, although I wouldn't expect it to explode with that line and just output a couple warnings instead.
>
> This snippet was extract from a more complex code. The name of the functions, module and variables do not seem to affect the failure.
>
> I tried to further debug the issue but I could not pinpoint the failure. Let me know if I can help any further.
>
> Thank you for your time,
>
>
> José Valim
> www.plataformatec.com.br
> Founder and Lead Developer
>
>
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs
More information about the erlang-patches
mailing list