[MapServer-dev] Schrödinger's bug

Seth G sethg at geographika.co.uk
Sun Oct 16 02:07:00 PDT 2022

Hi all,

I've been trying to get MapScript for Python working for MapServer 8.0 using Visual Studio 2022 and the release-1930-x64 SDK from GISInternals- see issue https://github.com/MapServer/MapServer/issues/6628

In summary, whenever you try and save a Mapfile to a file in Python (all versions from 2.7 to 3.10 are affected) there is a "Windows fatal exception: access violation". 

Note, everything builds fine when using Visual Studio 2019 (and the release-1928-x64 SDK) with the same MapServer code. 

The worst thing is that when running a DEBUG version of the code - everything works fine. The exception only works in RELEASE version, which means my "debugging" involves modifying code, recompiling and rerunning. 

The fact it doesn't work in RELEASE version strongly implies that VS2022 is doing some optimization which causes the issue. I'm not sure how best to progress this, and hoping someone on the list may have some ideas. 

- With each of the fuzzing fixes, I've been hoping the issue will be resolved. Could it be the case that memory is getting corrupted and causing the issue?
- Is it likely the cause is a bug in the MapServer code which causes something to be optimized away that shouldn't be?
- Is there any chance there is a bug in VS2022 itself rather than anything in MapServer?
- Commenting out various parts of `writeWeb, and `writeFeature` get things working again, but there seems to be no logic to this - e.g. commenting out half of the `writeLayer` means it works again (with no changes to `writeWeb`), but commenting out a single line in `writeWeb` also gets it working, removing parts of `writeFeature` also works, a Mapfile with one LAYER works one with 2 LAYERS doesn't..
- the `writeMapToString` [1] is only called using MapScript. Would it be worth adding an option to map2img to dump out an input Mapfile to test this without any MapScript?

Thanks for any input!


[1] https://github.com/MapServer/MapServer/blob/e5a53178b056f0da83ec8e5a2e0412a50d0ca3a6/mapfile.c#L5904

twitter: @geographika

More information about the MapServer-dev mailing list