Opened 13 years ago

Last modified 13 years ago

#3911 new defect

Length of DATA parameter causes MapServer crash

Reported by: geographika Owned by: hobu
Priority: normal Milestone:
Component: Input - Native MS SQL Server Support Version: 5.6
Severity: major Keywords: mssql data character length
Cc:

Description

In the DATA configuration for a layer read from SQL Server 2008, if the string is longer than 1077 characters then I get the following error in IIS7:

HTTP Error 500.0 - Internal Server Error C:\Mapserver\bin\mapserv.exe - The FastCGI process exited unexpectedly

Also nothing is written to the MapServer debug log, which makes it very hard to diagnose the issue. I was able to circumvent the issue by using table synonyms to reduce the query length.

A simplified layer config is shown below. Adding in a commented section to bring the charcater count over the 1077 limit can reproduce the crash.

To add a commented section prefix it with a double dash --

LAYER
    NAME 'Test'
    CONNECTIONTYPE PLUGIN 
    PLUGIN "C:\Mapserver\bin\ms\plugins\mssql2008\msplugin_mssql2008.dll"
    PROCESSING "CLOSE_CONNECTION=DEFER"
    CONNECTION "server=..."
    TYPE LINE
    DATA "GEOM from (
          --add random text here to reproduce issue
          SELECT mytable.ID, mytable.GEOM FROM mytable) AS tbl 
          USING UNIQUE ID USING SRID=29902" 
    DUMP TRUE

Whilst it is probably not necessary to increase the character limit, it should not cause the MapServer process to crash, and should log a message such as "DATA parameter above X character limit"

Attachments (1)

mssql.patch (454 bytes ) - added by geographika 13 years ago.
Increase preprocessing string size

Download all attachments as: .zip

Change History (4)

comment:1 by geographika, 13 years ago

Probably liked to line http://trac.osgeo.org/mapserver/browser/trunk/mapserver/mapmssql2008.c#L513

char        query_string_temp[10000];       /* Should be big enough */

by geographika, 13 years ago

Attachment: mssql.patch added

Increase preprocessing string size

comment:2 by geographika, 13 years ago

Severity: normalmajor

A much harder to find bug which is related to this is the following:

A WFS query is made to a layer with a DATA parameter of 1000+ characters (in my case 1026)

The preprocessor query is truncted - as this only allows 1000 characters. The end of the string is garbled. E.g.

SELECT top 0 * FROM (SELECT .......) AS mytaVëEëþ

The garbled text seems fairly random, and every now and again included a slash such as tVë/àþ

This causes the preprocessor query to fail, but the driver is still able to return the geometry by wrapping the DATA query such as:

SELECT GEOM.STAsBinary(),convert(varchar(36), Id) from (SELECT....--DATA clause here

Geometry is still returned, BUT none of the attributes are included causing various client side code to fail - but only when the alias includes a slash.

Not nice to bebug..

Anyway I believe this can be easily resolved by increasing the 1000 character limit to match the 10000 used elsewhere. Patch attached.

comment:3 by geographika, 13 years ago

In summary (as I can't modify the previous comments?):

It is not the:

 char        query_string_temp[10000];       /* Should be big enough */

But the limit of 1000 characters as shown in the patch. There is also a second 1000 character variable on line 564 which may or may not cause issues.

With DATA parameters just over 1000 characters features can still be returned with errors, but if there are any special punctuation marks at the end of the string it may not bring back attributes, but won't fail.

Note: See TracTickets for help on using tickets.