inets: HTTP client race condition

Witold Baryluk <>
Fri Jul 31 12:48:27 CEST 2009


Hi,

Today I have encountered strange problem in simple scenario with inets.
when I'm doing concurrent requests to the same server which responds
slowly.

go() ->
inets:start(),
lists:foldl(fun(_, _) ->
  spawn(fun() -> {ok, {A,B,C}}=http:request("http://www.wp.pl/"), io:format("ok ~p~n", [A]) end),
  receive after 1334 -> ok end
end,
0,
lists:seq(1, 5)
).

It is quite indeterministic, just try many times or change parameters.

Some of the request will crash:


** Reason for termination == 
**
{bad_return_value,{error,{invalid_version,">Zwiastuny</a></li><li><a"}}}


where the string comes directly from TCP port.


Full crash report in attachment.

I'm running Debian GNU/Linux unstable on x86,
Erlang OTP R13B01 erts-5.7.2, hipe enabled.

Using shell, i can crash them even if only two requests are running.


regards.

-- 
Witold Baryluk <>
Erlang Training & Consulting Ltd

-------------- next part --------------
=ERROR REPORT==== 31-Jul-2009::11:56:11 ===
** Generic server <0.1455.0> terminating 
** Last message in was {tcp,#Port<0.8412>,
                            <<">Zwiastuny</a></li><li><a href=\"http://www.multikino.pl/\" >Multikino</a></li></ul><p><a href=\"37833,serwisy.html\" onclick=\"return NowaSg.submenuPopoverShow(37833)\">wi?cej »</a></p></div></li><li><a href=\"http://kobieta.onet.pl/\">Kobieta</a><div><ul><li><a href=\"http://uroda.onet.pl/\" >Uroda</a></li><li><a href=\"http://zdrowie.onet.pl/\" >Zdrowie</a></li><li><a href=\"http://gotowanie.onet.pl/\" >Gotowanie</a></li><li><a href=\"http://slub.onet.pl/\" >?lub</a></li><li><a href=\"http://dziecko.onet.pl/\" >Dziecko</a></li><li><a href=\"http://partnerstwo.onet.pl/\" >Zwi?zki</a></li><li><a href=\"http://zyciegwiazd.onet.pl/\" >?ycie gwiazd</a></li><li><a href=\"http://gala.onet.pl/\" >Gala</a></li><li><a href=\"http://rodziceradza.pl\" >Rodzice radz?</a></li><li><a href=\"http://perfumeria.onet.pl\" >Perfumeria</a></li></ul><p><a href=\"37834,serwisy.html\" onclick=\"return NowaSg.submenuPopoverShow(37834)\">wi?cej »</a></p></div></li><li><a href=\"http://moto.onet.pl\">Motoryzacja</a><div><ul><li><a href=\"http://moto.onet.pl/samochody.html?node=4\" >Baza samochod?w</a></li><li><a href=\"http://moto.onet.pl/kup_nowe.html?node=35#01fcec42ec\" >Kup nowe</a></li><li><a href=\"http://kupuzywane.moto.onet.pl/\" >Kup u?ywane</a></li><li><a href=\"http://moto.onet.pl/5,dzial.html?node=5\" >Wiadomo?ci</a></li><li><a href=\"http://moto.onet.pl/14,1,premiery,dzial.html?node=14\" >Premiery</a></li><li><a href=\"http://moto.onet.pl/testy.html?node=19\" >Testy</a">>}
** When Server state == {state,
                            {request,#Ref<0.0.0.8701>,<0.1459.0>,0,http,
                                {"www.onet.pl",80},
                                "/",[],get,
                                {http_request_h,undefined,"keep-alive",
                                    undefined,undefined,undefined,undefined,
                                    undefined,undefined,undefined,undefined,
                                    undefined,undefined,undefined,undefined,
                                    undefined,undefined,"www.onet.pl",
                                    undefined,undefined,undefined,undefined,
                                    undefined,undefined,undefined,undefined,
                                    undefined,[],undefined,undefined,
                                    undefined,undefined,"0",undefined,
                                    undefined,undefined,undefined,undefined,
                                    undefined,[]},
                                {[],[]},
                                {http_options,"HTTP/1.1",infinity,true,[],
                                    undefined,false},
                                "http://www.onet.pl/",[],none,[]},
                            {tcp_session,
                                {{"www.onet.pl",80},<0.1455.0>},
                                false,http,#Port<0.8412>,1,keep_alive},
                            {"HTTP/1.0",200,"OK"},
                            {http_response_h,"private","keep-alive",
                                "Fri, 31 Jul 2009 09:55:58 GMT",undefined,
                                undefined,undefined,undefined,
                                "1.0 sq4.m1r2.onet:80 (squid)",undefined,
                                undefined,undefined,undefined,undefined,
                                undefined,undefined,"AOLserver/3.4.2 SP/1",
                                "Accept-Encoding",undefined,undefined,
                                undefined,undefined,"90817",undefined,
                                undefined,undefined,
                                "text/html; charset=iso-8859-2",
                                "Thu, 31 Jul 2008 10:01:15 GMT",undefined,
                                [{"p3p",
                                  "CP=\"ALL DSP COR IVD IVA PSD PSA TEL TAI CUS ADM CUR CON SAM OUR IND\""},
                                 {"x-cache","HIT from sq4.m1r2.onet"},
                                 {"x-cache-lookup",
                                  "HIT from sq4.m1r2.onet:80"}]},
                            undefined,
                            {httpc_response,parse,[nolimit,false]},
                            {[],[]},
                            {[],[]},
                            keep_alive,[],nolimit,nolimit,
                            {options,
                                {undefined,[]},
                                0,2,5,120000,2,disabled,false,inet,default,
                                default},
                            {timers,[],#Ref<0.0.0.8691>},
                            httpc_manager,undefined}
** Reason for termination == 
** {bad_return_value,{error,{invalid_version,">Zwiastuny</a></li><li><a"}}}

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: To jest cz??? wiadomo?ci podpisana cyfrowo
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20090731/756bc8fd/attachment.bin>


More information about the erlang-bugs mailing list