Opened 13 years ago

Closed 12 years ago

#3598 closed defect (fixed)

Calling mapserv with no query string causes mapserver fastcgi process to exit

Reported by: ajiintser Owned by: sdlime
Priority: normal Milestone:
Component: MapServer FastCGI Version: 6.0
Severity: normal Keywords:
Cc: warmerdam, homme

Description

Error


We are using lighthttpd, fastcgi and Mapserver 5.2.0. We were seeing a lot of the following errors in our logs:

2010-11-04 04:53:50: (mod_fastcgi.c.2462) unexpected end-of-file (perhaps the fastcgi process died): pid: 925 socket: unix:/var/tmp/lighttpd/mapserver-fastcgi.socket-3

This is causing a lot of valid requests being returned http 500 errors.

Cause


We traced this back to a load balancer pinging Mapserver with the url /cgi-bin/mapserv with no query string. This causes the mapserv process to exit and the NEXT request will sometimes get the error above. We can see by hitting /cgi-bin/mapserv the process will die.

By looking at the lighttpd page /server-counters we see: fastcgi.backend.0.4.died: 3 This gets incremented for every time you hit /cgi-bin/mapserv with no query string.

Code causing the issue


mapserv.c Line 1201:

mapserv->request->NumParams = loadParams(mapserv->request);

This is inside the "while( FCGI_Accept() >= 0 ) {" loop. Inside this loop we should not call exit but call continue so the process does not exit but stays alive to process the next request. However cgiutils.loadParams does call exit.

cgiutil.c Line 179:

if(strlen(s)==0) {

msIO_printf("Content-type: text/html%c%c",10,10); msIO_printf("No query information to decode. QUERY_STRING is set, but empty.\n"); exit(1);

}

This method exits even if Mapserver is running in fastcgi mode.

Ramifications


1) Using /cgi-bin/mapserv to determine if mapserver is up will cause intermittent http 500 errors. 2) Can be used to deny service by making the fastcgi mapserv processes stop. These process will fire up again, but a lot of requests will get http 500 errors as the backend processes have stopped.

Change History (5)

comment:1 by ajiintser, 13 years ago

As an additional note, we looked into the trunk code and believe this is still an issue with the latest release.

comment:2 by sdlime, 13 years ago

Cc: warmerdam added

comment:3 by homme, 12 years ago

Version: 5.26.0

I have just come across this issue on my fastcgi setup using mapserver 6.0.1.

There are also a number of other locations in the code where the mapserv process exits in fastcgi mode but should continue accepting requests. loadParams() is littered with exit() calls, and I have also encountered one when using a QUERY_STRING without a mode parameter e.g.

http://localhost/fcgi-bin/mapserv?map=/path/to/mapserver-6.0.1/tests/test.map

This appears to be due to exit() calls in writeError() in mapserv.c.

Basically I don't believe mapserv in fastcgi mode should exit after it generates output that is designed to be sent over HTTP (i.e. there is a Content-type header).

comment:4 by homme, 12 years ago

Cc: homme added

comment:5 by tbonfort, 12 years ago

Resolution: fixed
Status: newclosed

This issue has been resolved in r12907

Note: See TracTickets for help on using tickets.