[erlang-bugs] Parameterized modules aren't correct treated by HiPE

Sergey S <>
Fri Feb 13 23:20:32 CET 2009


While playing with parameterized modules, I found that they aren't
completely supported by HiPE. It was expressed that my HiPE compiled
server involving parameterized modules crashed, when I started it.
Details are below.

I know that parameterized modules we have in R12B5 is an experimental
feature, but if it's going to be an official part of the language this
bug report may be helpful to make it more stable than it is now.

I've just written a sample to be used as a demonstration of this issue.

Here is shell session, illustrating how to reproduce it in three
steps. The same steps without involving HiPE don't lead to crash:

% --------------------------------------------------------------
Erlang (BEAM) emulator version 5.6.5 [source] [smp:2]
[async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.6.5  (abort with ^G)
1> c(srv, [native]), c(req).
2> srv:start().
3> srv ! doit.

=ERROR REPORT==== 13-Feb-2009::23:08:52 ===
Error in process <0.53.0> with exit value:

% --------------------------------------------------------------

And two modules you need to repeat above steps:

% -srv.erl-------------------------------------------------

start() ->
    spawn(fun() -> register(?MODULE, self()), loop(fun handler/1) end).

handler(Req) ->
    io:format("# ~p~n", [Req:get_time()]).

loop(Handler) ->
	doit ->
	stop ->
% --------------------------------------------------

% -req.erl-------------------------------------------------
-module(req, [Time]).

get_time() -> Time.
% --------------------------------------------------

Actually this is more or less how Mochiweb passes its request data
(socket, headers etc) to internal funcions through a callback one. It
seems that Mochiweb has been using parameterized modules to hide
request representation from an user since its first versions. So it
becomes impossible to compile such a http-handler using HiPE :(


More information about the erlang-bugs mailing list