MagickDrawPolygonPrimitive() hanging indefinitely
Posted: 2012-06-14T09:30:26-07:00
Hello all,
I am developing an application which renders a very large number of many-vertex polygons onto a map image. I'm using ImageMagick to do the drawing, and I'm experiencing a very bizarre problem. The application has been tested to run perfectly on several Linux boxes and 32-bit Macs, but when run on 64-bit Mac OS X Lion (other 64-bit Mac OS releases have not yet been tested), the application *sometimes* finishes (with exactly the expected output) but other times hangs, apparently infinitely long (or just *extremely* long) or until forcibly killed. Judging by other tests I've done, it seems to be the case that this only happens if the polygons are complex enough; that is, they have enough vertices (or possibly the vertices are close enough together). The ImageMagick libraries are installed using MacPorts, and through the use of gdb (The GNU debugger) I've been able to determine that the application is getting stuck inside of the MagickDrawPolygonPrimitive() function. I'd like to compile the libraries with gdb symbols enabled (which, when running gdb, provides references back to the source code in the compiled code so that the developer can see much more clearly what is going on in the program being debugged). But the libraries are installed using MacPorts, and I can't seem to discern whether or not there is any way to tell MacPorts I want to do this (all it would take is a -g flag to the compiler when building the libraries).
I have tried building ImageMagick myself from source, with the -g flag. Oddly, when I do this and then build my application against the libraries, the problem of hanging in MagickDrawPolygonPrimitive() goes away entirely (making it very difficult to debug ), but another problem is introduced, instead: after the output has been generated, I cannot seem to get it written out to any compressed image format (I've tried png, tiff, and jpg). I have gone after *that* one with gdb and found that the function call to the appropriate image compression library (e.g. libpng) is coming back false, so the data cannot be compressed. If I just write to a bitmap instead, the output shows up (every time) and is confirmed to be correct. This is despite inclusion of flags like --with-png when running the configure script.
So in a nutshell, on the MacPorts build of ImageMagick, my application *sometimes* fails to get through all polygon-drawing calls, but if it finishes, it always succeeds in writing the output file even if compressed. On my build of ImageMagick, my application always succeeds in generating the correct image data, and can always write it to a bitmap, but can never write it to a compressed format.
My question is three-fold:
1) Can anyone tell me if there is some way I could get gdb symbols compiled into the MacPorts build of ImageMagick so that I can get in there and see if I can't find out what's going on in MagickDrawPolygonPrimitive()? I'm very curious about this.
2) Does anyone have any off-the-top-of-the-head insight as to what could be causing MagickDrawPolygonPrimitive to get "stuck" but only on this particular platform, and only sometimes?
3) Any ideas as to what could be causing my build to fail in writing its output to a compressed image format? Ideally, I'd like to get question #1 answered, but if I could get my own build of ImageMagick working it would at least be a temporary solution.
Thanks very much in advance for any help!
I am developing an application which renders a very large number of many-vertex polygons onto a map image. I'm using ImageMagick to do the drawing, and I'm experiencing a very bizarre problem. The application has been tested to run perfectly on several Linux boxes and 32-bit Macs, but when run on 64-bit Mac OS X Lion (other 64-bit Mac OS releases have not yet been tested), the application *sometimes* finishes (with exactly the expected output) but other times hangs, apparently infinitely long (or just *extremely* long) or until forcibly killed. Judging by other tests I've done, it seems to be the case that this only happens if the polygons are complex enough; that is, they have enough vertices (or possibly the vertices are close enough together). The ImageMagick libraries are installed using MacPorts, and through the use of gdb (The GNU debugger) I've been able to determine that the application is getting stuck inside of the MagickDrawPolygonPrimitive() function. I'd like to compile the libraries with gdb symbols enabled (which, when running gdb, provides references back to the source code in the compiled code so that the developer can see much more clearly what is going on in the program being debugged). But the libraries are installed using MacPorts, and I can't seem to discern whether or not there is any way to tell MacPorts I want to do this (all it would take is a -g flag to the compiler when building the libraries).
I have tried building ImageMagick myself from source, with the -g flag. Oddly, when I do this and then build my application against the libraries, the problem of hanging in MagickDrawPolygonPrimitive() goes away entirely (making it very difficult to debug ), but another problem is introduced, instead: after the output has been generated, I cannot seem to get it written out to any compressed image format (I've tried png, tiff, and jpg). I have gone after *that* one with gdb and found that the function call to the appropriate image compression library (e.g. libpng) is coming back false, so the data cannot be compressed. If I just write to a bitmap instead, the output shows up (every time) and is confirmed to be correct. This is despite inclusion of flags like --with-png when running the configure script.
So in a nutshell, on the MacPorts build of ImageMagick, my application *sometimes* fails to get through all polygon-drawing calls, but if it finishes, it always succeeds in writing the output file even if compressed. On my build of ImageMagick, my application always succeeds in generating the correct image data, and can always write it to a bitmap, but can never write it to a compressed format.
My question is three-fold:
1) Can anyone tell me if there is some way I could get gdb symbols compiled into the MacPorts build of ImageMagick so that I can get in there and see if I can't find out what's going on in MagickDrawPolygonPrimitive()? I'm very curious about this.
2) Does anyone have any off-the-top-of-the-head insight as to what could be causing MagickDrawPolygonPrimitive to get "stuck" but only on this particular platform, and only sometimes?
3) Any ideas as to what could be causing my build to fail in writing its output to a compressed image format? Ideally, I'd like to get question #1 answered, but if I could get my own build of ImageMagick working it would at least be a temporary solution.
Thanks very much in advance for any help!