joswa / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

CGI process creation frequently fails #267

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a simple Perl script.
2. Attempt to access it through Mongoose.
3. Sometimes it works; sometimes it doesn't.

What is the expected output? What do you see instead?
I expect to get the result of the Perl script however instead I get an error in 
the browser (Chrome):

Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without 
sending any data.

Inspecting the mongoose error log shows the following error:
[1310797238] [error] [client 127.0.0.1] GET /get_data.pl: line 1198: 
CreateProcess(c:\users\max\wow\web\get_data.pl): 193

What version of the product are you using? On what operating system?
Mongoose 3.0 on Win7, 64-bit.

Please provide any additional information below.

Note this doesn't happen 100% of the time, probably around 50% failure rate and 
it seems to happen in waves (a wave of 10 failures followed by 10 successes). 
Here's an example .cgi that generates this error:

#!c:\bin\perl\bin\perl

print <<END_HTML;
content-type: text/html

<html>
<head>
<title>My Home Page</title>
</head>
<body>
asdlkhasldkhasd
</body>
</html>

Original issue reported on code.google.com by max.dyck...@gmail.com on 16 Jul 2011 at 6:23

GoogleCodeExporter commented 9 years ago
Apologies, the final line of my example script was cut off. The correct .cgi 
would be:

#!c:\bin\perl\bin\perl

print <<END_HTML;
content-type: text/html

<html>
<head>
<title>My Home Page</title>
</head>
<body>
asdlkhasldkhasd
</body>
</html>
END_HTML

Original comment by max.dyck...@gmail.com on 16 Jul 2011 at 6:25

GoogleCodeExporter commented 9 years ago
I have exactly same issue with mongoose-3.0.exe with python. 

Interstingly the other version mongoose-2.10.exe works correctly with the same 
python script. The contents of the .conf are exactly same. 

Only changes in the .conf created by respective versions are- 
cgi_extensions .py,.cgi,.pl,.php    <<<<< added .py here
listening_ports 80                  <<<<< changed from default 8080

Original comment by pupak...@gmail.com on 17 Jul 2011 at 3:14

GoogleCodeExporter commented 9 years ago
I have the same problem, without even using CGI. I only use the document_root 
option.

Using Ubuntu 11.04 64-bit and mongoose 3.0

Original comment by peter.kn...@gmail.com on 2 Aug 2011 at 8:39

GoogleCodeExporter commented 9 years ago
Do you mean that even serving static content sometimes fail?

Original comment by valenok on 2 Aug 2011 at 3:36

GoogleCodeExporter commented 9 years ago
I don't recall ever having had this issue serving static content. Certainly the 
error message I am getting looks like it's specific to spawning new processes 
to handle a CGI execution:

line 1198: CreateProcess(c:\users\max\wow\web\get_data.pl): 193

Funnily enough, this issue has caused me to make sure I write my pages with 
great error handling. :)

Original comment by max.dyck...@gmail.com on 2 Aug 2011 at 3:48

GoogleCodeExporter commented 9 years ago
Oh. Looking at that.
wow - is it world of warcraft related, by the way?

Original comment by valenok on 2 Aug 2011 at 4:38

GoogleCodeExporter commented 9 years ago
Hah yes I have a few WoW related web apps that I am working on locally. :)

If you can't reproduce it for some reason then I can test a new build at home 
tonight. I hit the error a LOT, so I would be surprised that you hadn't noticed 
it if it was happening on all setups. My Windows 7 install is very fresh, just 
nuked it a couple of weeks ago, and my PC is pretty high end.

Original comment by max.dyck...@gmail.com on 2 Aug 2011 at 4:43

GoogleCodeExporter commented 9 years ago
Hehe, the high-end PC may be the cause of the problem :-)
It might be a race condition in the mongoose code that is triggered when the 
machine is very fast.
I'll try to reproduce it, unless I go play some WOW :-)

Original comment by valenok on 2 Aug 2011 at 4:48

GoogleCodeExporter commented 9 years ago
Can you try out the new build please?
I pushed the development binary to 
http://code.google.com/p/mongoose/downloads/list

Original comment by valenok on 3 Aug 2011 at 6:07

GoogleCodeExporter commented 9 years ago
I will as soon as I get home after work (about 6pm PST). Thanks!

Original comment by max.dyck...@gmail.com on 3 Aug 2011 at 6:10

GoogleCodeExporter commented 9 years ago
Hi! I'm afraid to say it's even worse. Now CGI processes will NEVER start. I 
logged over 100 attempts at the same script, before I checked the error log and 
noticed it was clearly never going to succeed:

[1312428852] [error] [client 127.0.0.1] POST /get_events.pl: line 1202: 
CreateProcess(c:\users\max\wow\web\c:\users\max\wow\web\get_events.pl): 2
[1312428969] [error] [client 127.0.0.1] GET /get_events.pl: line 1202: 
CreateProcess(c:\users\max\wow\web\c:\users\max\wow\web\get_events.pl): 2

You've got the document root in there twice! :)

(And to confirm, when I switch back to mongoose-3.0.exe using the same .conf, I 
get six failed loads and then a successful load of the page).

Original comment by max.dyck...@gmail.com on 4 Aug 2011 at 3:40

GoogleCodeExporter commented 9 years ago
Hey guys,

Had the same issue in C++ when switching from 2.xx to 3.0 as well.

My C++ app builds a JSON object then prints the data with mg_printf(...).

Tracked it down to the fact that the std BUFSIZ declaration is 512.

mg_printf uses this to set the initial size of the char buffer used in the 
output.

In 2.10 there was a separate declaration:

#define BUFSIZ      4096

Which overrode that SMALL 512.

So by putting this back in my code I can use mg_printf with strings up to 4096 
chars.

Or you can set it to whatever you want.

Doesn't really work if you're using the binary though.

Enjoy :P

Original comment by mattdlockyer@gmail.com on 1 Dec 2011 at 1:06

GoogleCodeExporter commented 9 years ago
Could you try the latest development version please, 
https://github.com/downloads/valenok/mongoose/mongoose.exe ?
I hope the issue is fixed now.

Original comment by valenok on 22 Sep 2012 at 3:12