New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRID layer with no label block crashes MapServer > v 7.0.4 #5466

Closed
cnieman opened this Issue Jul 24, 2017 · 9 comments

Comments

Projects
None yet
3 participants
@cnieman
Contributor

cnieman commented Jul 24, 2017

I am trying to draw a map with a grid layer that has no labels.

If I put in an empty label block, the map works with the label defaults for font, size, color, etc. But, if I comment out the label block, I get a crash. The grid with no label block works with MapServer 7.0.4 , but not MapServer 7.0.6, branch-7.0, or master.

I've attached a test mapfile, and the GDB output I got with a build from master.

test.map.txt
gdb.txt

@sdlime

This comment has been minimized.

Member

sdlime commented Jul 28, 2017

Hi @cnieman: Thanks for the test case, I'll have a look. --Steve

@cnieman

This comment has been minimized.

Contributor

cnieman commented Aug 2, 2017

@sdlime

This comment has been minimized.

Member

sdlime commented Aug 2, 2017

I think this is something more fundamental associated with grids and the calls in the gdb output are a red herring. Personally I think we should turn labeling off if the labelformat is set to "".

@cnieman

This comment has been minimized.

Contributor

cnieman commented Aug 2, 2017

To clarify, the way we are using the grid is to get the intersections and labels from msGraticuleLayerGetIntersectionPoints to insert labels into a PDF around the map, so that's why I have a LABELFORMAT, but no LABEL block in my example. We don't want labels on the map, we place them around the map with custom code that formats them as we want and inserts the map into an SVG.

I believe leaving the LABELFORMAT out would result in not getting appropriate grid values from msGraticuleLayerGetIntersectionPoints. See attached images.

With LABELFORMAT "%g"
With LABELFORMAT

With LABELFORMAT line commented out
With LABELFORMAT commented out

@cnieman

This comment has been minimized.

Contributor

cnieman commented Dec 18, 2017

Is there any more information I can provide with respect to this issue?

@sdlime

This comment has been minimized.

Member

sdlime commented Dec 21, 2017

I can replicate the issue but I need someone with better gdb skills than I have to actually find the offending code. @rouault, could I pick your brain on the best way to debug this?

@rouault rouault closed this in e82d376 Dec 21, 2017

@rouault

This comment has been minimized.

Contributor

rouault commented Dec 21, 2017

valgrind ./shp2img -m grid.map -o out.png
==23204== Memcheck, a memory error detector
==23204== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==23204== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==23204== Command: ./shp2img -m grid.map -o out.png
==23204== 
==23204== Conditional jump or move depends on uninitialised value(s)
==23204==    at 0x4C2EDA1: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==23204==    by 0x4F5CD8F: msFreeShape (mapprimitive.c:160)
==23204==    by 0x4EF1004: msGraticuleLayerNextShape (mapgraticule.c:302)
==23204==    by 0x4F69409: msLayerNextShape (maplayer.c:337)
==23204==    by 0x4F9D07B: msDrawVectorLayer (mapdraw.c:1094)
==23204==    by 0x4F9B92C: msDrawLayer (mapdraw.c:811)
==23204==    by 0x4F9A2CC: msDrawMap (mapdraw.c:388)
==23204==    by 0x40248B: main (shp2img.c:296)
==23204== 

I've just committed a fix. Appears it is indeed a regression due to changes I done in that area. I have added a test case that triggers this situation so we don't regress on that anymore

@sdlime

This comment has been minimized.

Member

sdlime commented Dec 22, 2017

Awesome, thanks!

@cnieman

This comment has been minimized.

Contributor

cnieman commented Dec 22, 2017

Thanks! I hoped to try this out today, but other things have gotten in the way. I will definitely check on it when I'm back at work in the new year, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment