Page 1 of 1

Error in annotate

Posted: 2011-06-30T06:32:31-07:00
by jimc99999
MacOS 10.6.7
ruby 1.8.7
rmagick 2.13.1
ImageMagick 6.7.0-7 q8
freetype 2.4.5

I have a program that builds images based on data and other images. With certain fonts, above a certain image size, I'm getting a memory error in annotate.

Code: Select all

Memory allocation failed `No such file or directory' @ fatal/draw.c/DrawImage/3112 
./lib/layout.rb:611:in `annotate'
./lib/layout.rb:611:in `lay_out_text'
At one point I got a segfault, which gave a crash log as well.

Code: Select all

Process:         ruby [45160]
Path:            /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
Identifier:      ruby
Version:         ??? (???)
Code Type:       X86-64 (Native)
Parent Process:  ruby [44997]

PlugIn Path:       /opt/local/lib/libMagickCore.4.dylib
PlugIn Identifier: libMagickCore.4.dylib
PlugIn Version:    5.1.0 (compatibility 5.0.0)

Date/Time:       2011-06-30 00:42:06.209 -0400
OS Version:      Mac OS X 10.6.7 (10J869)
Report Version:  6

Exception Type:  EXC_BAD_ACCESS (SIGABRT)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000001050df020
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Application Specific Information:
abort() called

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libSystem.B.dylib             	0x00007fff86e265d6 __kill + 10
1   libSystem.B.dylib             	0x00007fff86ec6c77 __abort + 103
2   libSystem.B.dylib             	0x00007fff86ec6ce5 abort_report_np + 0
3   libruby.1.dylib               	0x0000000100016f18 rb_sys_fail + 0
4   libruby.1.dylib               	0x000000010007b27c rb_trap_restore_mask + 194
5   libSystem.B.dylib             	0x00007fff86e3866a _sigtramp + 26
6   libMagickCore.4.dylib         	0x0000000104955aae TraceBezier + 734
7   libMagickCore.4.dylib         	0x0000000104960172 DrawImage + 12946
8   libMagickCore.4.dylib         	0x00000001049042d6 RenderFreetype + 6694
9   libMagickCore.4.dylib         	0x0000000104904536 RenderType + 214
10  libMagickCore.4.dylib         	0x000000010490538e AnnotateImage + 1278
11  RMagick2.bundle               	0x000000010123dc89 Draw_annotate + 650
12  libruby.1.dylib               	0x00000001000197c3 rb_rescue + 1004
13  libruby.1.dylib               	0x0000000100024a41 rb_proc_call + 1558
I can send the whole crash log if that will help. I tried reverting to ImageMagick 6.6.9, with exactly the same result. There is plenty of memory available. If I build the file at higher resolutions, the same error occurs earlier in the process but the script will be using double the memory as when this occurs on a smaller file. If the file being built is small enough, the error does not occur at all.

The error only occurs with some fonts, with others the files build successfully. The fonts which cause errors are Apple-Chancery-Chancery, LucidaCalligraph-Italic, Commercial-Script-Std-Regular, which are all .ttf files. Other fonts which do not trigger the error are
Arial-Narrow-Bold, Arial-Narrow-Regular, PumpEF-Bold-Regular, Brush-Script-MT-Italic, Arial-Narrow-Bold-Italic, Engravers'-Old-English-Regular, Agincourt-LET-Plain, which run the gamut of .ttf, .pfb, and .otf font files.

This program has worked in production for a couple years now, the problem has arisen since I updated the OS from 10.5 to 10.6 as well as reinstalling ImageMagick and supporting programs from MacPorts. The problem is reproducible on a Mac Pro with 8G RAM as well as my MacBook Pro with 4G RAM I use for development. Switching the kernel from 32-bit to 64-bit had no effect either.

Since this appeared to be a memory-related error, the first thing I did was go back through the ruby program and much more aggressively call .destroy! on the small images generated via annotate, which also had no effect other than showing the program running with a few mb less memory used (not much when the program is taking 800M to 1.5G memory)

With ImageMagick 6.6.9-9, here is the error:

Code: Select all

Memory allocation failed `No such file or directory' @ fatal/draw.c/DrawImage/3099 
./lib/layout.rb:611:in `annotate'
./lib/layout.rb:611:in `lay_out_text'
which is a slightly different line number, if that helps at all. On my test case that is failing, the fonts are being generated at 22.5 and 15.75 points.

I've tried disabling OpenMP, but that also had no effect. I'm going to work on installing previous versions of freetype to see if that has any effect, and possibly see if there are alternatives to annotate that will do what I need. In the meantime, any suggestions will be welcome.

Re: Error in annotate

Posted: 2011-06-30T07:18:32-07:00
by magick
The problem you reported is fixed in ImageMagick 6.7.0-10 Beta. It will be released within a few days. Try it and if your problem persists, let us know.

Re: Error in annotate

Posted: 2011-06-30T08:19:33-07:00
by jimc99999
Wow, that was fast. Sometimes I can't believe the support we get from an open-source software product.

In any case, reverting to freetype 2.3.12 made no difference, as I guess you'd know by now. ImageMagick 6.6.7 also does not appear to have this problem, so I can at least get the machine back into production until 6.7.0-10 is released.

Thanks again for the quick response.