Page 1 of 2

convert ss1.xwd ss1.jpg, Segmentation fault

Posted: 2009-02-14T06:22:02-07:00
by BenCollver
$ cat /etc/slackware-version
Slackware 12.2.0

$ convert --version
Version: ImageMagick 6.4.9-4 2009-02-14 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC

$ convert ss1.xwd ss1.jpg
Segmentation fault

The file ss1.xwd is available compressed at the following location.
http://bencollver.googlepages.com/ss1.xwd.gz

Re: convert ss1.xwd ss1.jpg, Segmentation fault

Posted: 2009-02-14T07:51:24-07:00
by magick
Your image converted without complaint with ImageMagick 6.4.9-4 on our Fedora system. Post a stack trace so we can track where the fault occurs:
  • gdb convert
    run ss1.xwd ss1.jpg
    bt

Re: convert ss1.xwd ss1.jpg, Segmentation fault

Posted: 2009-02-15T05:31:13-07:00
by BenCollver

Code: Select all

$ gdb im/bin/convert
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-slackware-linux"...
(gdb) run ss1.xwd ss1.jpg
Starting program: /home/ben/im/bin/convert ss1.xwd ss1.jpg
[Thread debugging using libthread_db enabled]
[New Thread 0xb69ac700 (LWP 4429)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb69ac700 (LWP 4429)]
0x00574152 in ?? ()
(gdb) bt
#0  0x00574152 in ?? ()
#1  0xb777af3b in ?? () from /usr/lib/libgs.so.8
#2  0x083f6df8 in ?? ()
#3  0xb7b065c0 in st_DCT_state () from /usr/lib/libgs.so.8
#4  0xb7aa2af8 in ?? () from /usr/lib/libgs.so.8
#5  0xb7aa2af8 in ?? () from /usr/lib/libgs.so.8
#6  0xb7aa2b38 in ?? () from /usr/lib/libgs.so.8
#7  0x00000054 in ?? ()
#8  0xbfb3a8cc in ?? ()
#9  0xb7bd9644 in ?? () from /usr/lib/libgs.so.8
#10 0xbfb3ac34 in ?? ()
#11 0xbfb3aa20 in ?? ()
#12 0xbfb398e8 in ?? ()
#13 0xb777cab9 in jinit_memory_mgr () from /usr/lib/libgs.so.8
Backtrace stopped: frame did not save the PC
(gdb) 

Re: convert ss1.xwd ss1.jpg, Segmentation fault

Posted: 2009-02-15T07:55:23-07:00
by magick
The stack trace does not show any calls from ImageMagick. Instead it shows a trace from Ghostscript's libgs. Can you verify you are calling the ImageMagick convert command?

Re: convert ss1.xwd ss1.jpg, Segmentation fault

Posted: 2009-02-15T12:32:37-07:00
by BenCollver
Does this verify that I am calling the ImageMagick convert command?

Code: Select all

$ /home/ben/im/bin/convert --version
Version: ImageMagick 6.4.9-4 2009-02-14 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC

$ gdb /home/ben/im/bin/convert
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-slackware-linux"...
(gdb) l convert.c:100 
95        TimerInfo
96          timer;
97      
98        unsigned long
99          iterations;
100     
101       MagickCoreGenesis(*argv,MagickTrue);
102       exception=AcquireExceptionInfo();
103       iterations=1;
104       status=MagickFalse;
(gdb) b convert.c:101
Breakpoint 1 at 0x80518d2: file utilities/convert.c, line 101.
(gdb) run ss1.xwd ss1.jpg
Starting program: /home/ben/im/bin/convert ss1.xwd ss1.jpg
[Thread debugging using libthread_db enabled]
[New Thread 0xb6b4a700 (LWP 6411)]
[Switching to Thread 0xb6b4a700 (LWP 6411)]

Breakpoint 1, main (argc=3, argv=0xbfad9014) at utilities/convert.c:101
101       MagickCoreGenesis(*argv,MagickTrue);
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x00574152 in ?? ()
(gdb) bt
#0  0x00574152 in ?? ()
#1  0xb7918f3b in ?? () from /usr/lib/libgs.so.8
#2  0x083f6df8 in ?? ()
#3  0xb7ca45c0 in st_DCT_state () from /usr/lib/libgs.so.8
#4  0xb7c40af8 in ?? () from /usr/lib/libgs.so.8
#5  0xb7c40af8 in ?? () from /usr/lib/libgs.so.8
#6  0xb7c40b38 in ?? () from /usr/lib/libgs.so.8
#7  0x00000054 in ?? ()
#8  0xbfad686c in ?? ()
#9  0xb7d77644 in ?? () from /usr/lib/libgs.so.8
#10 0xbfad6bd4 in ?? ()
#11 0xbfad69c0 in ?? ()
#12 0xbfad5888 in ?? ()
#13 0xb791aab9 in jinit_memory_mgr () from /usr/lib/libgs.so.8
Backtrace stopped: frame did not save the PC
(gdb) 

Re: convert ss1.xwd ss1.jpg, Segmentation fault

Posted: 2009-02-15T12:57:45-07:00
by magick
We're clueless why ImageMagick is calling the Ghostscript delegate library for the XWD format but that is where the process stops. We need a complete backtrace so we know where ImageMagick is calling the Ghostscript library. With that trace we may be able to determine why its call Ghostscript. As mentioned we cannot reproduce the problem on any of our Fedora, Centos, Windows, or Mac OS systems. Until we have a complete backtrace we are unable to determine if the problem is in ImageMagick or in Ghostscript.

Re: convert ss1.xwd ss1.jpg, Segmentation fault

Posted: 2009-02-15T13:10:37-07:00
by BenCollver
I get a different backtrace from the version of ImageMagick included with slackware 12.2. Does this help?

Code: Select all

$ /usr/bin/convert --version
Version: ImageMagick 6.4.3 2008-10-05 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC

$ gdb /usr/bin/convert
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-slackware-linux"...
(no debugging symbols found)
(gdb) run ss1.xwd ss1.jpg
Starting program: /usr/bin/convert ss1.xwd ss1.jpg
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0xb67dab30 (LWP 6525)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb67dab30 (LWP 6525)]
0xb7cf9883 in IsGrayImage () from /usr/lib/libMagickCore.so.1
(gdb) bt
#0  0xb7cf9883 in IsGrayImage () from /usr/lib/libMagickCore.so.1
#1  0xb7f00aa0 in ?? () from /usr/lib/libMagickCore.so.1
#2  0x08068880 in ?? ()
#3  0x0806ba48 in ?? ()
#4  0x00000020 in ?? ()
#5  0x0806ba48 in ?? ()
#6  0x08053c18 in ?? ()
#7  0x08053a20 in ?? ()
#8  0x0804e9d0 in ?? ()
#9  0xb7df76d4 in CompareSplayTreeString () from /usr/lib/libMagickCore.so.1
#10 0xb7d1145c in WriteImage () from /usr/lib/libMagickCore.so.1
#11 0xb7d11d73 in WriteImages () from /usr/lib/libMagickCore.so.1
#12 0xb7bd7ca2 in ConvertImageCommand () from /usr/lib/libMagickWand.so.1
#13 0x08048c1f in main ()

Re: convert ss1.xwd ss1.jpg, Segmentation fault

Posted: 2009-02-15T13:15:58-07:00
by pprkut
I get a similar backtrace on 12.2.

I tried recompiling imagemagick with debugging enabled, but couldn't find any --enable-debug or similar. I just didn't strip the binaries, but the backtrace got
complete unuseful (ie, no library calls visible). Do I need to enable something specifically to get all debug symbols?

Re: convert ss1.xwd ss1.jpg, Segmentation fault

Posted: 2009-02-15T13:38:03-07:00
by magick
So far the trace is not giving us enough information to debug. Let's try something else. First does this command fault:
  • convert ss1.xwd null:
How 'bout this command:
  • convert logo: ss1.jpg
Now post a URL to the output of this command:
  • convert -debug trace,all ss1.xwd ss1.jpg
If you're ambitious rebuild ImageMagick without OpenMP support and see if that makes a difference;
  • cd ImageMagick-6.4.9-4
    ./configure --disable-openmp
    make
    make install
    convert ss1.xwd ss1.jpg

Re: convert ss1.xwd ss1.jpg, Segmentation fault

Posted: 2009-02-15T14:23:02-07:00
by pprkut
magick wrote:So far the trace is not giving us enough information to debug. Let's try something else. First does this command fault:
  • convert ss1.xwd null:
works

How 'bout this command:
  • convert logo: ss1.jpg
works

Now post a URL to the output of this command:
  • convert -debug trace,all ss1.xwd ss1.jpg
http://www.liwjatan.at/files/im-trace.log.tar.bz2

If you're ambitious rebuild ImageMagick without OpenMP support and see if that makes a difference;
  • cd ImageMagick-6.4.9-4
    ./configure --disable-openmp
    make
    make install
    convert ss1.xwd ss1.jpg
Actually, Slackware does that already. So I tried to recompile with --enable-openmp, but it didn't make any difference.

Re: convert ss1.xwd ss1.jpg, Segmentation fault

Posted: 2009-02-15T14:39:03-07:00
by magick
Unfortunately the trace did not help much. It may be memory corruption since the log shows the program failing when its destroying an image. Perhaps the memory corruption is due to the X11 library since it is invoked to read the XWD image format. Can anyone set us up with an account so we can build ImageMagick and reproduce the problem to aid in debugging?

Re: convert ss1.xwd ss1.jpg, Segmentation fault

Posted: 2009-02-15T15:27:33-07:00
by pprkut
Unfortunately not. However, as it is the standard slackware package failing, it *should* be the same across all slackware installs. So any slackware install should do.

In the meantime, I played a little bit around and tried different output formats. Here's what I got:
Worked: png, bmp, exr
Seemed to work (created malfomed file): mng, sxw
Failed: jpg, jp2, gif, xpm

Where it failed, it always failed at this step:

Code: Select all

2009-02-15T23:24:15+01:00 0:01 0.020u 6.4.3 Cache convert[18124]: cache.c/unknown/3569/Cache
  open ss1.xwd[0] (anonymous memory, 919x949 6.654mb)
2009-02-15T23:24:15+01:00 0:01 0.080u 6.4.3 Configure convert[18124]: configure.c/unknown/528/Configure
  Searching for configure file: "/usr/share/ImageMagick-6.4.3/config/delegates.xml"
2009-02-15T23:24:15+01:00 0:01 0.080u 6.4.3 Configure convert[18124]: configure.c/unknown/528/Configure
  Searching for configure file: "/usr/lib/ImageMagick-6.4.3/config/delegates.xml"
2009-02-15T23:24:15+01:00 0:01 0.080u 6.4.3 Configure convert[18124]: configure.c/unknown/528/Configure
  Searching for configure file: "/usr/share/doc/ImageMagick-6.4.3/delegates.xml"
2009-02-15T23:24:15+01:00 0:01 0.080u 6.4.3 Configure convert[18124]: configure.c/unknown/528/Configure
  Searching for configure file: "/usr/share/ImageMagick-6.4.3/delegates.xml"
2009-02-15T23:24:15+01:00 0:01 0.080u 6.4.3 Configure convert[18124]: configure.c/unknown/528/Configure
  Searching for configure file: "/root/.magick/delegates.xml"
2009-02-15T23:24:15+01:00 0:01 0.080u 6.4.3 Configure convert[18124]: configure.c/unknown/528/Configure
  Searching for configure file: "delegates.xml"
2009-02-15T23:24:15+01:00 0:01 0.080u 6.4.3 Configure convert[18124]: delegate.c/unknown/1178/Configure
  Loading delegate map "/usr/lib/ImageMagick-6.4.3/config/delegates.xml" ...
Segmentation fault
Converting from one of the formats it worked with to one it failed does work too, although convert takes about 3 times longer and uses 97% cpu.

Re: convert ss1.xwd ss1.jpg, Segmentation fault

Posted: 2009-02-16T19:13:49-07:00
by BenCollver
magick wrote:Can anyone set us up with an account so we can build ImageMagick and reproduce the problem to aid in debugging?
Please provide an SSH public key for me to add to authorized_hosts and I will provide an IP address and user name.

Thank you,

Ben

Re: convert ss1.xwd ss1.jpg, Segmentation fault

Posted: 2009-02-17T11:19:58-07:00
by magick
The problem is that Ghostscript's libgs is built with a different version of libJPEG and when ImageMagick calls the JPEG jinit_memory_mgr() method it causes the program to fault. The solution is to rebuild ImageMagick like this:
  • cd ImageMagick-6.4.9-4
    ./configure --without-gslib
    make
    make install
In the mean-time we will modify the build environment so by default it does not include libgs support unless specifically requested with --with-gslib.

Re: convert ss1.xwd ss1.jpg, Segmentation fault

Posted: 2009-02-17T12:59:36-07:00
by BenCollver
Thank you for diagnosing this.

Code: Select all

$ ldd /usr/bin/convert /home/ben/im/bin/convert /usr/lib/libgs.so|grep jpeg
        libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0xb79e6000)
        libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0xb7638000)
        libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0xb7706000)
I notice that there is only one version of libjpeg on my system. Does this mean that libgs.so is using a different version of libjpeg than it was built with?