couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filipe David Manana <>
Subject using Erlang's debugger with couchdb
Date Tue, 01 Dec 2009 22:34:49 GMT

I am having a strange situation. With Erlang's debugger , I set a
breakpoint in couch_httpd_db.erl, second clause of the function
db_attachment_req (around line 1012), and when uploading an
attachment, I get a badmatch exception. It seems to be related to the
following case statement:

data = case couch_httpd:body_length(Req) of
                    undefined ->
                    {unknown_transfer_encoding, Unknown} ->
                        exit({unknown_transfer_encoding, Unknown});
                    chunked ->
                        fun(MaxChunkSize, ChunkFun, InitState) ->
                            couch_httpd:recv_chunked(Req, MaxChunkSize,
                                ChunkFun, InitState)
                    0 ->
                    Length when is_integer(Length) ->
                        fun() -> couch_httpd:recv(Req, 0) end;
                    Length ->
                        exit({length_not_integer, Length})

A part of the stack trace:

[error] [<0.221.0>] Uncaught error in HTTP request: {error,{badmatch,34}}
[info] [<0.221.0>] Stacktrace: [{couch_httpd_db,db_attachment_req,
                                "curl/7.18.2 (i486-pc-linux-gnu)
libcurl/7.18.2 OpenSSL/0.9.8g zlib/ libidn/1.10"},

If I don't use the debugger (yet even with modules compiled using the
erlc flag +debug_info) everything goes fine, no exceptions at all.
Adding a print statement before that case statement:

io:format("~n~nBODY LENGTH: ~p~n~n", [couch_httpd:body_length(Req)]),

gives the right value to stdout (an integer).

Why do I get this strange behaviour? Is Erlang's debugger buggy?
How do you debug your code? Do you use something else ?


Filipe David Manana,
PGP key -

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

View raw message