Hello,
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)
end;
0 ->
<<"">>;
Length when is_integer(Length) ->
fun() -> couch_httpd:recv(Req, 0) end;
Length ->
exit({length_not_integer, Length})
end,
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,
[{httpd,
{mochiweb_request,#Port<0.3985>,'PUT',
"/testedb/testdoc1/readme.txt",
{1,1},
{5,
{"user-agent",
{'User-Agent',
"curl/7.18.2 (i486-pc-linux-gnu)
libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.10"},
{"host",
{'Host',"localhost:5984"},
{"accept",
{'Accept',"*/*"},
nil,
{"content-type",
{'Content-Type',"text/plain"},
{"content-length",
{'Content-Length',"34"},
nil,nil},
nil}},
nil},
nil}}},
"127.0.0.1",'PUT',
[<<"testedb">>,<<"testdoc1">>,<<"readme.txt">>],
{dict,6,16,16,8,80,48,
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 ?
cheers
--
Filipe David Manana,
[email protected]
PGP key - http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xC569452B
"Reasonable men adapt themselves to the world.
Unreasonable men adapt the world to themselves.
That's why all progress depends on unreasonable men."