Re: Compiler crash with 'inline_list_funcs' and "fun Fun/Arity" notation

Anthony Ramine <[email protected]>
Newsgroups gmane.comp.lang.erlang.bugs,gmane.comp.lang.erlang.patches
Message-ID <[email protected]>
Hello,

This patch fixes the bug by forbidding inlining of variables which values are local fun references outside of application contexts.

	git fetch https://github.com/nox/otp.git fix-fname-inlining

	https://github.com/nox/otp/compare/erlang:maint...fix-fname-inlining
	https://github.com/nox/otp/compare/erlang:maint...fix-fname-inlining.patch

Regards,

-- 
Anthony Ramine

Le 17 mai 2013 à 20:06, Anthony Ramine a écrit :

> Hello,
> 
> Shorter test case, showing the problem comes from the inline itself and not inline_list_funcs:
> 
> -module(test).
> -compile(inline).
> -export([foo/0]).
> 
> foo() ->
>    F = fun bar/1,
>    fun (X) when X =:= F -> X end.
> 
> bar(X) -> X.
> 
> If you run the core_lint pass, you can see where the problem comes from:
> 
> $ erlc +clint test.erl
> test: illegal guard expression in foo/0
> 
> The inliner inlines `when 'erlang':'=:='(X, F)` to `'erlang':'=:='(X, 'bar'/1)` but local fun references can't appear in guards.
> 
> I'll try to make a patch.
> 
> Regards,
> 
> -- 
> Anthony Ramine
> 
> Le 17 mai 2013 à 10:55, Masatake Daimon a écrit :
> 
>> Hello,
>> 
>> Compiling the following module makes the compiler crash. I'm using
>> R16B.
>> 
>> ===== test.erl =====
>> -module(test).
>> -compile(inline).
>> -compile(inline_list_funcs).
>> -export([foo/0]).
>> 
>> foo() ->
>>   lists:map(fun bar/1, [1]).
>> 
>> bar(X) -> X.
>> 
>> ===== the crash ====
>> % erlc test.erl
>> test: function '-foo/0-lists^map/1-0-'/1+15:
>> Internal consistency check failed - please report this bug.
>> Instruction: {move,{x,0},{yy,0}}
>> Error:       {invalid_store,{yy,0},term}:
>> 
>> 
>> Note that the problem disappears with any of these changes:
>> 
>> * Commenting out "-compile(inline)."
>> * Commenting out "-compile(inline_list_funcs)."
>> * Changing the definition of foo/0 to:
>>     foo() ->
>>         lists:map(fun bar/1, []).   % [] instead of [1]
>> * Changing the definition of foo/0 to:
>>     foo() ->
>>         lists:map(fun (A) -> bar(A) end, [1]).
>> 
>> Regards,
>> -- 
>> 大門 正岳 <[email protected]>
>> _______________________________________________
>> erlang-bugs mailing list
>> [email protected]
>> http://erlang.org/mailman/listinfo/erlang-bugs
> 

_______________________________________________
erlang-bugs mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-bugs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.