[erlang-questions] on_load attribute + inline compile flag

Yiannis Tsiouris gtsiour@REDACTED
Sat Feb 11 19:42:52 CET 2012


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@REDACTED [~/Desktop]>>= erlc my_on_load.erl
> yiannis@REDACTED [~/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@REDACTED [~/Desktop]>>= erlc +inline my_on_load.erl
> yiannis@REDACTED [~/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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: my_on_load.erl
Type: text/x-erlang
Size: 176 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120211/b3cdf412/attachment.bin>


More information about the erlang-questions mailing list