Page 1 of 1

BUG : annotate No Thread Safe

Posted: 2011-01-24T03:15:41-07:00
by dadagogo
hi,

I'm using IM 6.6.7-1. I am trying to put text into image with the "annotate" method.

Code: Select all

        image.modifyImage();
	Color col("white");
	image.fillColor(col);
	image.fontPointsize(20);
	std::string Font="-*-bitstream charter-medium-r-normal-*-*-*-*-*-*-*-iso8859-1";
	image.font(Font);
	image.modifyImage();
	Geometry geo(0,0);
	image.annotate(message, geo);
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)
David

Re: BUG : annotate No Thread Safe

Posted: 2011-01-24T06:28:50-07:00
by magick
What OS are you using? What release?

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.

Re: BUG : annotate No Thread Safe

Posted: 2011-01-24T06:41:13-07:00
by dadagogo
I'm using Ubuntu 4.4.3-4ubuntu5 (gcc 4.4.3) and ImageMagick-6.6.7-1.

Re: BUG : annotate No Thread Safe

Posted: 2011-01-24T06:43:37-07:00
by magick
Try a non-X11 font such as Helvetica or Times. Let's see if the problem is specific to multi-threaded X11.

Also try calling image.annotate() once before you generates any threads. Maybe the problem is with the X11 initialization.

Re: BUG : annotate No Thread Safe

Posted: 2011-01-24T06:45:40-07:00
by dadagogo
For the OS : Ubuntu 10.04.1 LTS (Linux version 2.6.32-27-generic)

Re: BUG : annotate No Thread Safe

Posted: 2011-01-24T06:54:27-07:00
by dadagogo
Thanks lot,
No problem with Helvetica font !!

david

Re: BUG : annotate No Thread Safe

Posted: 2011-01-24T07:23:40-07:00
by magick
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.

Re: BUG : annotate No Thread Safe

Posted: 2011-01-25T01:45:49-07:00
by dadagogo
Hi,
I called image.annotate() once before go into threading code using X11 font and I have same error.

Re: BUG : annotate No Thread Safe

Posted: 2011-01-25T10:40:29-07:00
by magick
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.

Re: BUG : annotate No Thread Safe

Posted: 2011-01-26T01:31:59-07:00
by dadagogo
ok, thanks.
As, there is no problem with other fonts (No X11) and other OS. I m not sure that it is necessary to single thread the entire X1.