Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
This code works well in a single threaded program but i have errors in multi-threaded program :
==17172== Thread 2:
==17172== Invalid read of size 8
==17172== at 0xAE06B10: _XOpenLC (in /usr/lib/libX11.so.6.3.0)
==17172== by 0xAE06C07: _XlcCurrentLC (in /usr/lib/libX11.so.6.3.0)
==17172== by 0xAE06FF8: XSupportsLocale (in /usr/lib/libX11.so.6.3.0)
==17172== by 0x88CDCA7: XGetAnnotateInfo (xwindow.c:2885)
==17172== by 0x8763E76: RenderX11 (annotate.c:1906)
==17172== by 0x8767461: GetTypeMetrics (annotate.c:734)
==17172== by 0x8768931: AnnotateImage (annotate.c:236)
==17172== by 0x81B09CD: Magick::Image::annotate(std::string const&, Magick::Geometry const&, MagickCore::GravityType, double) (Image.cpp:451)
==17172== Address 0xfdc79b0 is 0 bytes inside a block of size 16 free'd
==17172== at 0x4C270BD: free (vg_replace_malloc.c:366)
==17172== by 0xAE069C7: _XCloseLC (in /usr/lib/libX11.so.6.3.0)
==17172== by 0xADFF5AB: ??? (in /usr/lib/libX11.so.6.3.0)
==17172== by 0xADEEECE: XrmCombineDatabase (in /usr/lib/libX11.so.6.3.0)
==17172== by 0x88CCCFD: XGetResourceDatabase (xwindow.c:3391)
==17172== by 0x87642D6: RenderX11 (annotate.c:1847)
==17172== by 0x8767461: GetTypeMetrics (annotate.c:734)
==17172== by 0x8768931: AnnotateImage (annotate.c:236)
==17172== by 0x81B09CD: Magick::Image::annotate(std::string const&, Magick::Geometry const&, MagickCore::GravityType, double) (Image.cpp:451)
==17172==
==17172== Invalid read of size 8
==17172== at 0xADC93CD: XFreeFont (in /usr/lib/libX11.so.6.3.0)
==17172== by 0x8763EA3: RenderX11 (annotate.c:1913)
==17172== by 0x8767461: GetTypeMetrics (annotate.c:734)
==17172== by 0x8768931: AnnotateImage (annotate.c:236)
==17172== by 0x81B09CD: Magick::Image::annotate(std::string const&, Magick::Geometry const&, MagickCore::GravityType, double) (Image.cpp:451)
==17172== Address 0x8 is not stack'd, malloc'd or (recently) free'd
==17172==
==17172==
==17172== Process terminating with default action of signal 11 (SIGSEGV)
==17172== Access not within mapped region at address 0x8
==17172== at 0xADC93CD: XFreeFont (in /usr/lib/libX11.so.6.3.0)
==17172== by 0x8763EA3: RenderX11 (annotate.c:1913)
==17172== by 0x8767461: GetTypeMetrics (annotate.c:734)
==17172== by 0x8768931: AnnotateImage (annotate.c:236)
==17172== by 0x81B09CD: Magick::Image::annotate(std::string const&, Magick::Geometry const&, MagickCore::GravityType, double) (Image.cpp:451)
We tried a multi-threaded Magick++ program with your code snippet and it ran without complaint. We used 5 workers and 5 iterations each. We'll take a closer look at the problem but its always helpful if we can reproduce the problem. We're using Fedora Core 14. Perhaps older versions of the X11 libraries were not thread safe.
To help us debug, can you call image.annotate() once before you go into your threading code. Use the X11 font. We'll see if its an X11 initialization problem.
We could single thread the entire X11 annotation code. However, the problem may be isolated to your version of Ubuntu. We tried under Fedora 14, CentOS 5, and Mac OS X and multi-threaded X11 annotate succeeded without complaint.