Converting SVG to anything -> segfault

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

Post by magick »

We don't get a seg-fault with ImageMagick 6.2.6-8 but it does not render properly. ImageMagick 6.2.7 development can render it. 6.2.7 will be released in a few weeks.
gwhite

Conversion works on 6.2.8, but still segfaults

Post by gwhite »

IM 6.2.8 built on FC4 using locally compiled versions of gs and fontconfig specifically to get SVG support:

./configure PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig \
--with-perl=/usr/bin/perl

Some edits to the makefile were needed:

$ diff Makefile.orig Makefile
0a1
> # hacked to add fontconfig to animate
1595c1596
< GS_LIBS = -lgs
---
> GS_LIBS = -L/usr/local/lib -lgs
1659c1660
< LDFLAGS = -L/usr/X11R6/lib -lfreetype -lz -L/usr/lib
---
> LDFLAGS = -L/usr/X11R6/lib -lfreetype -L/usr/local/lib -lfontconfig -lz -L/usr/lib
1666c1667
< LIBRARY_EXTRA_CPPFLAGS =
---
> LIBRARY_EXTRA_CPPFLAGS = -I/usr/local/include
4438,4439c4439,4441
< utilities_animate_LDADD = $(LIBMAGICK) $(LIBWAND)
< utilities_animate_LDFLAGS = $(LDFLAGS)
---
> utilities_animate_CFLAGS = $(FONTCONFIG_CFLAGS)
> utilities_animate_LDADD = $(LIBMAGICK) $(LIBWAND) $(FONTCONFIG_LIBS)
> utilities_animate_LDFLAGS = $(LDFLAGS) -Wl,--trace-symbol=FcFini


"make check" reports "All 714 tests behaved as expected (33 expected failures)".

$ convert Legendre_poly.svg Legendre_poly.png
Segmentation fault

The resulting png file seems OK. I also get:

$ gdb identify
)gdb) run -list format
[...]
* native blob support

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208903456 (LWP 20558)]
0x0102a745 in ?? ()
(gdb) where
#0 0x0102a745 in ?? ()
#1 0x0015abbf in __cxa_finalize () from /lib/libc.so.6
#2 0x07412196 in ?? () from /usr/lib/libglib-2.0.so.0
#3 0x074903c0 in ?? () from /usr/lib/libglib-2.0.so.0
#4 0xbfd3cdac in ?? ()
#5 0xbfd3ce2b in ?? ()
#6 0x0741216e in ?? () from /usr/lib/libglib-2.0.so.0
#7 0x00000000 in ?? ()
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

We noticed that one of librsvg dependancies causes the segmentation fault. It has an improper signal handler or atexit() handler (we're guessing). You can fix the problem by adding --without-rsvg to your configure script command line. SVG will still convert but it will use the internal ImageMagick SVG render engine.
gwhite

Re: Conversion works on 6.2.8, but still segfaults

Post by gwhite »

Thanks. The workaround seems to be OK from limited tests. My librsvg is old, version 2.9.5.
hlovdal

Re: Converting SVG to anything -> segfault

Post by hlovdal »

The segfault seems to be related to text handling:

$ cat ok.svg
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="1000" height="1000" >
<circle cx="500" cy="500" r="500" fill="yellow" />
</svg>
$ convert ok.svg ok.png
$ ls -l ok.png
-rw-rw-r-- 1 hlovdal hlovdal 30234 Jul 25 01:45 ok.png
$

$ cat notok.svg
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="1000" height="1000" >
<text x="30" y="600" font-size="400" >TEST</text>
</svg>
$ convert notok.svg notok.png
Segmentation fault
$ ls -l notok.png
-rw-rw-r-- 1 hlovdal hlovdal 35698 Jul 25 01:46 notok.png
$

The notok.png file looks ok though, so some problem with regards to atexit sounds reasonable. I just downloaded, compiled and tested with ImageMagick-6.3.5-3 which still have this issue.
gwhite

Re: Converting SVG to anything -> segfault

Post by gwhite »

Which version of librsvg do you have? For completeness, your examples do work using the debian unstable version 7:6.2.4.5.dfsg1-1 of ImageMagick (built without librsvg).
hlovdal

Re: Converting SVG to anything -> segfault

Post by hlovdal »

I have a stock Fedora Code 6 version

$ rpm -qi librsvg2
Name : librsvg2 Relocations: (not relocatable)
Version : 2.16.1 Vendor: Red Hat, Inc.
Release : 1.fc6 Build Date: Sat 04 Nov 2006 09:52:10 PM CET
Install Date: Sun 21 Jan 2007 08:28:14 PM CET Build Host: hs20-bc2-4.build.redhat.com
Group : System Environment/Libraries Source RPM: librsvg2-2.16.1-1.fc6.src.rpm
Size : 435290 License: LGPL
Signature : DSA/SHA1, Thu 09 Nov 2006 04:52:22 PM CET, Key ID b44269d04f2a6fd2
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Summary : An SVG library based on cairo
Description :
An SVG library based on cairo.
$

In case of interest, here are the library versions directly linked to convert:

$ ldd `type -p convert` | awk '/=> \//{print $3}' | xargs rpm -qf | sort -u
ImageMagick-6.2.8.0-4.fc6
bzip2-libs-1.0.3-6.fc6
expat-1.95.8-8.2.1
fontconfig-2.4.1-3.fc6
freetype-2.2.1-17.fc6
glibc-2.5-18.fc6
lcms-1.15-1.2.2
libICE-1.0.1-2.1
libSM-1.0.1-3.1
libX11-1.0.3-7.fc6
libXau-1.0.1-3.1
libXdmcp-1.0.1-2.1
libXext-1.0.1-2.1
libXt-1.0.2-3.1.fc6
libjpeg-6b-37
libtiff-3.8.2-6.fc6
zlib-1.2.3-3
$

The 6.3.5-3 test installation I did is not linked to ImageMagick-6.2.8.0-4.fc6 and libtiff-3.8.2-6.fc6 but is also linked to libgomp-4.1.2-13.fc6.
gwhite

Re: Converting SVG to anything -> segfault

Post by gwhite »

The source of the original segfaults was with librsvg2. If you aren't using that, you must be using the internal svg code. I can confirm your observations for FC6. I notice that the
debian version which doesn't segfault is using libxml2 while the FC6 version of convert uses
expat. Since libxml2 is also available on FC6, can you try building convert with that (hopefully
just a different argument to configure).
Post Reply