When to mark an error as "reported"?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

When to mark an error as "reported"?

Eichner, Andreas - SID-NLKM
Hi devs,

I just found that msResetErrorList() in maperror.c does not reset the "isreported" field to MS_FALSE. This can cause strange error reporting behavior when in FastCGI mode. While checking the uses of this field I found that msWriteError() and msWriteErrorXML() mark errors as reported while msWriteErrorImage() does not.
The problem is that msWriteErrorImage() does not access the errorObj directly but uses msGetErrorString(). So my question is: is it OK to let msGetErrorString() mark the errors as reported or should this be done in msWriteErrorImage()?
I think it's truly a bug but I'm not sure what the best solution would be. Any ideas?

Regards,
Andreas

_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev
Reply | Threaded
Open this post in threaded view
|

Re: When to mark an error as "reported"?

Lime, Steve D (MNIT)

Hi Andreas: Do you have some examples of strange error reporting? Just trying to wrap my head around the issue. --Steve


From: mapserver-dev <[hidden email]> on behalf of Eichner, Andreas - SID <[hidden email]>
Sent: Wednesday, December 27, 2017 4:23:42 AM
To: [hidden email]
Subject: [mapserver-dev] When to mark an error as "reported"?
 
Hi devs,

I just found that msResetErrorList() in maperror.c does not reset the "isreported" field to MS_FALSE. This can cause strange error reporting behavior when in FastCGI mode. While checking the uses of this field I found that msWriteError() and msWriteErrorXML() mark errors as reported while msWriteErrorImage() does not.
The problem is that msWriteErrorImage() does not access the errorObj directly but uses msGetErrorString(). So my question is: is it OK to let msGetErrorString() mark the errors as reported or should this be done in msWriteErrorImage()?
I think it's truly a bug but I'm not sure what the best solution would be. Any ideas?

Regards,
Andreas

_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev

_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev
Reply | Threaded
Open this post in threaded view
|

Re: When to mark an error as "reported"?

Eichner, Andreas - SID-NLKM
Hallo Steve,

sorry for the late answer. A simple example is using a not existing map file:

The first request gives a correct error message and HTTP status 200:
# LANG=C wget -O- 'http://localhost/cgi-bin/mapserv.fcgi?map=/doesnotexist'
--2018-01-05 16:02:05--  http://localhost/cgi-bin/mapserv.fcgi?map=/doesnotexist
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: 'STDOUT'

<HTML>
<HEAD><TITLE>MapServer Message</TITLE></HEAD>
<!-- MapServer version 7.1-dev OUTPUT=PNG OUTPUT=JPEG SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=ICONV SUPPORTS=WMS_SERVER SUPPORTS=WFS_SERVER SUPPORTS=WCS_SERVER SUPPORTS=FASTCGI SUPPORTS=GEOS INPUT=JPEG INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE -->
<BODY BGCOLOR="#FFFFFF">
msLoadMap(): Regular expression error. MS_DEFAULT_MAPFILE_PATTERN validation failed.

2018-01-05 16:02:05 (47.2 MB/s) - written to stdout [449]

While any further request just gives:
LANG=C wget -O- 'http://localhost/cgi-bin/mapserv.fcgi?map=/doesnotexist'
--2018-01-05 16:05:03--  http://localhost/cgi-bin/mapserv.fcgi?map=/doesnotexist
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:80... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2018-01-05 16:05:03 ERROR 500: Internal Server Error.

Apache reports:
[core:error] [pid 3019] [client ::1:38224] End of script output before headers: mapserv.fcgi

This makes mod_fcgid kill the FCGI process due to this fatal error.

The problem is that error reporting is delegated to msCGIWriteError() which immediately returns because the "isreported" field was not reset:
void msCGIWriteError(mapservObj *mapserv)
{
  errorObj *ms_error = msGetErrorObj();

  if(!ms_error || ms_error->code == MS_NOERR || ms_error->isreported) {
    /* either we have no error, or it was already reported by other means */
    return;
  }

The empty response becomes a "internal server error" since the headers are also omitted.


Regards,
Andreas


> -----Original Message-----
> From: Lime, Steve D (MNIT) [mailto:[hidden email]]
> Sent: Sunday, December 31, 2017 6:43 PM
> To: Eichner, Andreas - SID; [hidden email]
> Subject: Re: When to mark an error as "reported"?
>
> Hi Andreas: Do you have some examples of strange error reporting? Just
> trying to wrap my head around the issue. --Steve
>
> ________________________________
>
> From: mapserver-dev <[hidden email]> on behalf of
> Eichner, Andreas - SID <[hidden email]>
> Sent: Wednesday, December 27, 2017 4:23:42 AM
> To: [hidden email]
> Subject: [mapserver-dev] When to mark an error as "reported"?
>
> Hi devs,
>
> I just found that msResetErrorList() in maperror.c does not reset the
> "isreported" field to MS_FALSE. This can cause strange error reporting
> behavior when in FastCGI mode. While checking the uses of this field I
> found that msWriteError() and msWriteErrorXML() mark errors as reported
> while msWriteErrorImage() does not.
> The problem is that msWriteErrorImage() does not access the errorObj
> directly but uses msGetErrorString(). So my question is: is it OK to let
> msGetErrorString() mark the errors as reported or should this be done in
> msWriteErrorImage()?
> I think it's truly a bug but I'm not sure what the best solution would
> be. Any ideas?
>
> Regards,
> Andreas
>
> _______________________________________________
> mapserver-dev mailing list
> [hidden email]
> https://lists.osgeo.org/mailman/listinfo/mapserver-dev
_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev