BUG : annotate No Thread Safe

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.
Post Reply
dadagogo
Posts: 6
Joined: 2011-01-24T02:57:05-07:00
Authentication code: 8675308

BUG : annotate No Thread Safe

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: BUG : annotate No Thread Safe

Post 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.
dadagogo
Posts: 6
Joined: 2011-01-24T02:57:05-07:00
Authentication code: 8675308

Re: BUG : annotate No Thread Safe

Post by dadagogo »

I'm using Ubuntu 4.4.3-4ubuntu5 (gcc 4.4.3) and ImageMagick-6.6.7-1.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: BUG : annotate No Thread Safe

Post 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.
dadagogo
Posts: 6
Joined: 2011-01-24T02:57:05-07:00
Authentication code: 8675308

Re: BUG : annotate No Thread Safe

Post by dadagogo »

For the OS : Ubuntu 10.04.1 LTS (Linux version 2.6.32-27-generic)
dadagogo
Posts: 6
Joined: 2011-01-24T02:57:05-07:00
Authentication code: 8675308

Re: BUG : annotate No Thread Safe

Post by dadagogo »

Thanks lot,
No problem with Helvetica font !!

david
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: BUG : annotate No Thread Safe

Post 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.
dadagogo
Posts: 6
Joined: 2011-01-24T02:57:05-07:00
Authentication code: 8675308

Re: BUG : annotate No Thread Safe

Post by dadagogo »

Hi,
I called image.annotate() once before go into threading code using X11 font and I have same error.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: BUG : annotate No Thread Safe

Post 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.
dadagogo
Posts: 6
Joined: 2011-01-24T02:57:05-07:00
Authentication code: 8675308

Re: BUG : annotate No Thread Safe

Post 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.
Post Reply