Ticket #2406 (closed defect: fixed)

Opened 11 months ago

Last modified 10 months ago

Blank PDF on Mapserver 5.0 with FastCGI

Reported by: ivanopicco Assigned to: mapserverbugs
Priority: normal Milestone: 5.0.1 release
Component: Output-PDF Version: 5.0
Severity: major Keywords:
Cc: warmerdam, zjames

Description

Map request with pdf as imagetype on Mapserv fastCGI returns blank (0 byte) file. The same mapfile and request work OK with shp2img, shp2pdf and cgi. Mapserv cgi is a simple copy from mapserv FastCGI binary, it was build from Mapserv 5.0.0 source code with ticket:2338 patch applied. Also tested without the patch. I used apache 2.2.4, mod_fcgid 2.1 and PDFlib-Lite-7.0.2 on CentOS release 4.5.

If more details are needed please let me know. Best Regards, Ivano

Debug log from CGI request:

Tue Nov 20 15:16:37 2007,5703,10.102.162.5,Prove,3,-25.000000 40.000000 25.000000 90.000000,-1.000000 -1.000000,w020n90 ,normal execution
[Tue Nov 20 15:16:37 2007].401373 CGI Request 1 on process 5703
[Tue Nov 20 15:16:37 2007].406622 msDrawRasterLayerLow(w020n90): entering.
[Tue Nov 20 15:16:37 2007].411209 msDrawGDAL(): src=0,0,4800,6000, dst=40,0,320,399

Debug log from FastCGI request:

Tue Nov 20 15:17:17 2007,2741,10.102.162.5,Prove,3,-25.000000 40.000000 25.000000 90.000000,-1.000000 -1.000000,w020n90 ,normal execution

Attachments

valgrind_CGI_PDF.txt (9.4 kB) - added by ivanopicco on 11/21/07 05:05:17.
valgrind_CGI_PNG.txt (9.4 kB) - added by ivanopicco on 11/21/07 05:05:38.

Change History

11/20/07 13:39:31 changed by dmorissette

  • cc set to warmerdam, zjames.
  • milestone set to 5.2 release.

Could you please try running that same request with the mapserv CGI under valgrind and see if it reports any error?

Also, can you share a small testcase to reproduce?

11/20/07 14:00:03 changed by zjames

One additional question: does the FastCGI binary fail to produce output with any of the other renderers?

11/21/07 05:05:17 changed by ivanopicco

  • attachment valgrind_CGI_PDF.txt added.

11/21/07 05:05:38 changed by ivanopicco

  • attachment valgrind_CGI_PNG.txt added.

11/21/07 05:10:33 changed by ivanopicco

Replying to dmorissette:

Could you please try running that same request with the mapserv CGI under valgrind and see if it reports any error?

I found an error, both with PDF and GDAL/PNG renderers, see attachments...

Also, can you share a small testcase to reproduce?

I used a simple raster layer from a DEM file:

 LAYER
    NAME "w020n90"
    DATA "/home/mapserver/data/w020n90/W020N90.DEM"
    TYPE RASTER
    STATUS ON
    DEBUG ON

    PROJECTION
      "init=epsg:4326"
    END
 END #LAYER

I think it can be reproducible with any raster layer.

A sample request: http://url/ms/raster?MODE=map&LAYER=w020n90&MAPEXT=-20%2040%2020%2090&MAPSIZE=400%20400&map.imagetype=pdf

Replying to zjames:

Jpeg: OK
Debug from FCGI

Wed Nov 21 08:47:03 2007,6624,10.102.190.102,Prove,3,-25.000000 40.000000 25.000000 90.000000,-1.000000 -1.000000,w020n90 ,normal execution

Debug from CGI

Wed Nov 21 08:47:26 2007,6841,10.102.190.102,Prove,3,-25.000000 40.000000 25.000000 90.000000,-1.000000 -1.000000,w020n90 ,normal execution
[Wed Nov 21 08:47:26 2007].524365 CGI Request 1 on process 6841
[Wed Nov 21 08:47:26 2007].528530 msDrawRasterLayerLow(w020n90): entering.
[Wed Nov 21 08:47:26 2007].533156 msDrawGDAL(): src=0,0,4800,6000, dst=40,0,320,399

Also with gif, GTiff and PNG

SVG: OK
Debug from FCGI

Wed Nov 21 09:01:54 2007,6624,10.102.190.102,Prove,3,-25.000000 40.000000 25.000000 90.000000,-1.000000 -1.000000,w020n90 ,normal execution

Debug from CGI

Wed Nov 21 09:02:34 2007,6853,10.102.190.102,Prove,3,-25.000000 40.000000 25.000000 90.000000,-1.000000 -1.000000,w020n90 ,normal execution
[Wed Nov 21 09:02:34 2007].85839 CGI Request 1 on process 6853
[Wed Nov 21 09:02:34 2007].90497 msDrawRasterLayerLow(w020n90): entering.
[Wed Nov 21 09:02:34 2007].95342 msDrawGDAL(): src=0,0,4800,6000, dst=40,0,320,399

SWF:OK
Debug from FCGI

Wed Nov 21 09:03:11 2007,6624,10.102.190.102,Prove,3,-25.000000 40.000000 25.000000 90.000000,-1.000000 -1.000000,w020n90 ,normal execution
Wed Nov 21 09:03:16 2007,6624,10.102.190.102,Prove,3,-25.000000 40.000000 25.000000 90.000000,-1.000000 -1.000000,w020n90 ,normal execution

Debug from CGI

Wed Nov 21 09:06:03 2007,6859,10.102.190.102,Prove,3,-25.000000 40.000000 25.000000 90.000000,-1.000000 -1.000000,w020n90 ,normal execution
[Wed Nov 21 09:06:03 2007].552485 CGI Request 1 on process 6859
[Wed Nov 21 09:06:03 2007].555944 msDrawRasterLayerLow(w020n90): entering.
[Wed Nov 21 09:06:03 2007].560676 msDrawGDAL(): src=0,0,4800,6000, dst=40,0,320,399
Wed Nov 21 09:06:04 2007,6865,10.102.190.102,Prove,3,-25.000000 40.000000 25.000000
 90.000000,-1.000000 -1.000000,w020n90 ,normal execution
[Wed Nov 21 09:06:04 2007].513076 CGI Request 1 on process 6865
[Wed Nov 21 09:06:04 2007].516573 msDrawRasterLayerLow(w020n90): entering.
[Wed Nov 21 09:06:04 2007].521294 msDrawGDAL(): src=0,0,4800,6000, dst=40,0,320,399

(follow-up: ↓ 5 ) 11/21/07 17:33:05 changed by dmorissette

I had a look at the valgrind outputs, and I don't think that error in Exit() from main() is related to MapServer. I've seen this before with FGS builds and suspect it's related to the build or runtime environment doing something odd, but in general the binaries work fine anyway since the failure is only on Exit.

Since both PDF and PNG outputs fail then I don't think this can be called PDF-specific issue. BTW, does the PNG test also return a 0 byte output?

I see 3 possibilities:

1- FastCGI issue or side-effect: Can you try with a build without FastCGI and see if the problem goes away?

2- Build/runtime libs or environment problem: did you try the same mapfile on another machine?

3- Problem with this specific .DEM data file: in this case we'd need a testcase to reproduce.

(in reply to: ↑ 4 ) 11/21/07 17:53:29 changed by ivanopicco

Replying to dmorissette:

Since both PDF and PNG outputs fail then I don't think this can be called PDF-specific issue. BTW, does the PNG test also return a 0 byte output?

No,PNG is OK

I see 3 possibilities: 1- FastCGI issue or side-effect: Can you try with a build without FastCGI and see if the problem goes away?

I think it's unnecessary. I tried with the same binary without mod_fcgid and it works!! Because this, I think you are right: maybe this is a FastCGI side-effect or maybe an environment problem.

2- Build/runtime libs or environment problem: did you try the same mapfile on another machine?

I tested it also with line and point vectors from Oracle Spatial. Same as previous tests, it works as CGI and it doesn't work on FCGI only on PDF imagetype.

Mind the difference on debug output, it's different but the generated images are both OK, why ?

11/22/07 12:58:58 changed by warmerdam

Scanning msSaveImagePDF() it appears that all output of the PDF to stdout is done using fwrite() and is presumably not being routed through the msIO_ layer which is required to return fastcgi stuff properly.

I can prepare a modification to mappdf.c if someone else can test it.

11/22/07 16:56:50 changed by assefa

Franck, I am setup with factgi locally so I can do the initial tests. I can confirm right now that I get a blank output in fatscgi and a pdf doc in non fast cgi.

11/22/07 17:11:53 changed by warmerdam

  • milestone changed from 5.2 release to 5.0.1 release.

Assefa, I have modify fwrite() to be msIO_fwrite() in trunk (r7070). If this works fine for you it should be ported back into 5.0 branch as well. Milestone set accordingly.

11/22/07 17:23:49 changed by assefa

tested in trunk and It works in fastcgi and in non facgi mode.

(follow-up: ↓ 11 ) 11/22/07 18:15:32 changed by assefa

back ported in 5.0.x r7071.

ivanopicco : please confirm that it works for you so we can close the bug.

(in reply to: ↑ 10 ) 11/26/07 04:03:14 changed by ivanopicco

No, it doesn't work. It works in non fastcgi mode and it doesn't in fastcgi (blank file). Tested with mapserver revision r7079 and also with patch from r7070 applied on mapserver 5.0.0 stable release.

11/27/07 12:18:00 changed by ivanopicco

Hi all, I made a simple mapfile you can use to reply my tests:

MAP
  NAME HELLO
  STATUS ON
  EXTENT 0 0 4000 3000
  SIZE 400 300
  IMAGECOLOR 255 200 255
  WEB
    IMAGEPATH "/tmp/"
    IMAGEURL "/tmp/"
  END
  LAYER
    NAME "credits"
    STATUS DEFAULT
    TRANSFORM FALSE
    TYPE ANNOTATION
    FEATURE
      POINTS
        200 150
      END
      TEXT 'Hello World!'
    END
    CLASS
      LABEL
        TYPE BITMAP
        COLOR 0 0 0
      END
    END
  END
END

With this you get an image with an "Hello World!" in the middle. With a pdf request you get a blank pdf file with CGI (it's a white page, not void) and a empty file with FastCGI

A sample request: http://localhost/cgi-bin/mapserv?map=hello-world.map&MODE=map&map_imagetype=pdf

I hope it could be useful

11/27/07 18:24:57 changed by assefa

I have retested with the map file provided and I get in both cases a valid empty pdf files. Not sure at this point why it does not work for you.

11/28/07 08:15:06 changed by ivanopicco

  • status changed from new to closed.
  • resolution set to fixed.

Don't mind me. I tried to rebuild all on another machine: it works. Thanks