Opened 17 years ago
Last modified 16 years ago
#2299 reopened defect
Python Mapscript bindings segfault
Reported by: | crschmidt | Owned by: | hobu |
---|---|---|---|
Priority: | high | Milestone: | FUTURE |
Component: | MapScript-Python | Version: | 5.0 |
Severity: | critical | Keywords: | |
Cc: | tomkralidis |
Description
wms = mapscript.mapObj(self.mapfile) req = mapscript.OWSRequest() req.setParameter("bbox", tile.bbox()) req.setParameter("width", str(tile.size()[0])) req.setParameter("height", str(tile.size()[1])) req.setParameter("srs", self.srs) req.setParameter("format", self.format()) req.setParameter("layers", self.layers) wms.loadOWSParameters(req)
This usage is still causing segfaults in 5.0.0-Beta5. It's possible a later build fixes this: I couldn't find an open bug. I'll upload a test case in a moment.
Change History (11)
comment:2 by , 17 years ago
using test.map in ./tests
import mapscript m = mapscript.mapObj('test.map') req = mapscript.OWSRequest() req.setParameter("bbox", '-93,42,-92,43') req.setParameter("layers", 'RASTER') m.loadOWSParameters(req)
comment:3 by , 17 years ago
Cc: | added |
---|
comment:4 by , 17 years ago
FYI #1088 never touched the request parameter. If the example above is in a WMS client sense, then yes, an exception should be returned by any given WMS server if the request parameter is not present.
Not sure why the segfault is happenning though. When I run the code in comment:2, my httpd logs never show a connection to the WMS server I'm invoking a request against. This tells me that the segfault happens before the request is sent.
comment:5 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Thanks for the GDB backtrace hobu. The segfault happened because of a test on request (looking for DescribeLayer) added in r6551, possibly to fix a side-effect of #1088 but we'll never know since there is no associated ticket.
I've added a check in r6873 to test for request being NULL before attempting a strcmp(). I'm not setup to test with Python MapScript so please reopen if the fix doesn't solve your issue.
comment:6 by , 17 years ago
When I try this now:
import mapscript req = mapscript.OWSRequest() map = mapscript.mapObj('./somemap.map') mapscript.msIO_installStdoutToBuffer() req.setParameter('SERVICE','WMS') req.setParameter('VERSION','1.1.1') req.setParameter('LAYERS','obs') #req.setParameter('REQUEST','DescribeLayer') map.OWSDispatch( req ) content_type = mapscript.msIO_stripStdoutBufferContentType() content = mapscript.msIO_getStdoutBufferBytes() if content_type == 'vnd.ogc.se_xml': content_type = 'text/xml' print 'Content-type: ' + content_type print print content
Uncommenting req.setParameter returns a non exception response. As is it returns an exception, as expected.
follow-up: 8 comment:7 by , 16 years ago
Milestone: | 5.0 release → FUTURE |
---|---|
Resolution: | fixed |
Status: | closed → reopened |
Summary: | Python Mapscript bindings segfault TileCache → Python Mapscript bindings segfault |
with SVN trunk, and using the tests/test.map, you get a segfault when setting styles to None. that can happen if you use cgi.parse_qsl(environQUERY_STRING)
import mapscript req = mapscript.OWSRequest() map = mapscript.mapObj('test.map') mapscript.msIO_installStdoutToBuffer() req.setParameter('SERVICE','WMS') req.setParameter('VERSION','1.1.1') req.setParameter('LAYERS','obs') req.setParameter('STYLE', None) map.OWSDispatch( req )
comment:8 by , 16 years ago
s/STYLE/STYLES/
Replying to brentp:
with SVN trunk, and using the tests/test.map, you get a segfault when setting styles to None. that can happen if you use cgi.parse_qsl(environQUERY_STRING)
import mapscript req = mapscript.OWSRequest() map = mapscript.mapObj('test.map') mapscript.msIO_installStdoutToBuffer() req.setParameter('SERVICE','WMS') req.setParameter('VERSION','1.1.1') req.setParameter('LAYERS','obs') req.setParameter('STYLE', None) map.OWSDispatch( req )
comment:9 by , 16 years ago
FYI, using the test snippet in comment:7, if I set any of the parameters to None, I get a segfault
comment:10 by , 16 years ago
i dont know if this helps diagnose, but it's possible to recreate a segfault with no None's -- running this on tests/test.map
import mapscript map = mapscript.mapObj('test.map') req = mapscript.OWSRequest() req.setParameter('SERVICE','WMS') req.setParameter('STYLES', ',') req.setParameter('VERSION','1.1.1') req.setParameter('LAYERS','RASTER') req.setParameter('REQUEST','GetMap') req.setParameter('WIDTH', '500') req.setParameter('HEIGHT', '500') req.setParameter('SRS', 'EPSG:4326') req.setParameter('FORMAT', 'image/png') req.setParameter('BBOX', '-8,51,-2,59') map.OWSDispatch( req )
comment:11 by , 16 years ago
Same segfault happens when tested similarly in Perl, for example:
$req->setParameter("STYLES", undef);