[erlang-questions] on_load attribute + inline compile flag

24 views
Skip to first unread message

Yiannis Tsiouris

unread,
Feb 11, 2012, 1:42:52 PM2/11/12
to erlang-q...@erlang.org
Hi all,

I've noticed the following thing that looks like a bug to me! I have
(the attached) my_on_load module that has an "on_load" hook. When I
BEAM-compile my_on_load.erl with no flags everything is fine; on_load
works as expected:

> yiannis@mosby [~/Desktop]>>= erlc my_on_load.erl
> yiannis@mosby [~/Desktop]>>= erl
> Erlang R15B (erts-5.9) [source] [64-bit] [smp:2:2] [rq:2]
[async-threads:0] [hipe] [kernel-poll:false]
>
> Eshell V5.9 (abort with ^G)
> 1> code:is_loaded(my_on_load).
> false
> 2> code:load_file(my_on_load).
> Bump! On_load works!
> {module,my_on_load}
> 4> code:is_loaded(my_on_load).
> {file,"/home/yiannis/Desktop/my_on_load.beam"}

While, I use "+inline" flag:

> yiannis@mosby [~/Desktop]>>= erlc +inline my_on_load.erl
> yiannis@mosby [~/Desktop]>>= erl
> Erlang R15B (erts-5.9) [source] [64-bit] [smp:2:2] [rq:2]
[async-threads:0] [hipe] [kernel-poll:false]
>
> Eshell V5.9 (abort with ^G)
> 1> code:is_loaded(my_on_load).
> false
> 2> code:load_file(my_on_load).
> {module,my_on_load}
> 4> code:is_loaded(my_on_load).
> {file,"/home/yiannis/Desktop/my_on_load.beam"}

No call to bump/0 is performed!

Is bump/0 optimized-out because it is not exported (due to the
"+inline")? Is this expected behaviour? Cause if it is, it 's not very
clear to me why! Plus, it took me the whole day to track a strange bug
that involved loading some NIFs with "on_load"! :-)

Best wishes,
Yiannis

--
Yiannis Tsiouris
Ph.D. student,
Software Engineering Laboratory,
National Technical University of Athens
WWW: http://www.softlab.ntua.gr/~gtsiour

my_on_load.erl

Björn Gustavsson

unread,
Feb 13, 2012, 3:00:37 AM2/13/12
to Yiannis Tsiouris, erlang-q...@erlang.org
On 2/11/12, Yiannis Tsiouris <gts...@softlab.ntua.gr> wrote:
> Is bump/0 optimized-out because it is not exported (due to the
> "+inline")?

Yes.

> Is this expected behaviour?

No, it is a bug. Thanks for the bug report.

/Björn

--
Björn Gustavsson, Erlang/OTP, Ericsson AB
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

Reply all
Reply to author
Forward
0 new messages