[erlang-questions] dbg:tracer() aborts on binary match

Jon Meredith jmeredith@REDACTED
Tue Aug 5 15:12:42 CEST 2008


Hi,

Thanks for the response.

I'm trying to look for the (unescaped) character string \r\n (0x5c   
0x72 0x5c 0x6e) from inside a squid access log with HTTP header  
information delimited by \r\n.  I think I've escaped it correctly.

Here's an alternative version with the escaping ambiguity removed.

%% Abort when running dbg:tracer().
%%
%% 1> binbug:bug().
%% size_object: matchstate term not allowedAbort trap

-module(binbug2).
-export([bug/0,
          parse_headers/4]).

parse_headers(<<92:8, 114:8, 92:8, 110:8, T/binary>>, Hdr, Hdrs, Toks)  
->
     parse_headers(T, <<>>, [Hdr | Hdrs], Toks).

bug() ->
     dbg:tracer(),
     dbg:p(all, call),
     dbg:tpl(?MODULE, []),
     parse_headers(<<92:8, 114:8, 92:8, 110:8, 10:8>>, <<>>, [], []).



Jon

On Aug 5, 2008, at 1:27 AM, Hynek Vychodil wrote:

> There is wrong escaping off topic. It should be:
>
> parse_headers(<<"\r\n", T/binary>>, Hdr, Hdrs, Toks) ->
>     parse_headers(T, <<>>, [Hdr | Hdrs], Toks).
>
> bug() ->
>     dbg:tracer(),
>     dbg:p(all, call),
>     dbg:tpl(?MODULE, []),
>     parse_headers(<<"\r\n]">>, <<"hdr1">>, [], []).
>
>
> On Tue, Aug 5, 2008 at 12:07 AM, Jon Meredith  
> <jmeredith@REDACTED> wrote:
> Hi,
>
> I'm writing a small parser for reading log lines.  When it didn't do
> what I expected I tried to use dbg:tracer() to see where it was going
> wrong and it aborted.  Here is the cut down minimal test case.
>
> I'm expecting it to match and then try and call parse_headers with Hdr
> added to the Hdrs list, but instead the VM aborts.  Am I doing
> something wrong/strange?
>
> Many thanks, Jon.
>
> %% Abort when running dbg:tracer().
> %%
> %% 1> binbug:bug().
> %% size_object: matchstate term not allowedAbort trap
>
> -module(binbug).
> -export([bug/0,
>          parse_headers/4]).
>
> parse_headers(<<"\\r\\n", T/binary>>, Hdr, Hdrs, Toks) ->
>     parse_headers(T, <<>>, [Hdr | Hdrs], Toks).
>
> bug() ->
>     dbg:tracer(),
>     dbg:p(all, call),
>     dbg:tpl(?MODULE, []),
>     parse_headers(<<"\\r\\n]">>, <<"hdr1">>, [], []).
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
>
> -- 
> --Hynek (Pichi) Vychodil

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080805/a75595de/attachment.htm>


More information about the erlang-questions mailing list