[erlang-bugs] R12B-3 +native pattern-matching bug

Kristoffer Warming <>
Fri Aug 8 16:03:36 CEST 2008

Hi :)

I am seeing faulty pattern matching in Erlang apps compiled to R12B-3
with +native, on 64-bit. Applies to older versions as well

More specificially this happens in Mochiweb in mochiweb_http.erl:request/2
Here is the code:

request(Socket, Body) ->
    case gen_tcp:recv(Socket, 0, ?IDLE_TIMEOUT) of
        {ok, {http_request, Method, Path, Version}} ->

headers(Socket, {Method, Path, Version}, [], Body);
        {error, {http_error, "\r\n"}} ->

request(Socket, Body);
        {error, {http_error, "\n"}} ->

request(Socket, Body);
        _Other ->

io:format("~nOther = ~p~n", [_Other]),   %my debug line


I put debugline under the default condition, to see what the case was.
Oddly enough it gave me this output:

Other = {ok,{http_request,'GET',{abs_path,"/"},{1,1}}}

which is a perfect match for the first condition.
...And It matches up just fine, if not compiled with +native

I also tried replacing the {http_request,Method,Path,Version} pattern with
_Message, and that gave a successful a match. _Message contained the same as
Other (without the 'ok')

To reproduce: grab Mochiweb source code (r84 of this writing), append
+native to ERLC_FLAGS in support/include.mk. Execute
`scripts/new_mochiweb.erl foo` to get skeleton files, and append
+native to foo/support/include.mk. here as well.
make,  and ./start-dev.sh

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20080808/5b28ded7/attachment.html>

More information about the erlang-bugs mailing list