[erlang-bugs] R12B-3 +native pattern-matching bug
Mikael Pettersson
mikpe@REDACTED
Fri Aug 8 20:25:06 CEST 2008
Kristoffer Warming writes:
> 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
>
> gen_tcp:close(Socket),
> exit(normal)
> end.
>
> 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
It would help if you could supply a small standalone test case.
More information about the erlang-bugs
mailing list