segfault in import

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

Re: segfault in import

Post by magick »

We suspect this patch to magick/xwindow.c fixes the fault:

Code: Select all

*** 3482,3489 ****
    resource_value=XGetResourceClass(database,client_name,"gammaCorrect",
      (char *) "True");
    resource_info->gamma_correct=IsMagickTrue(resource_value);
!   resource_info->image_geometry=ConstantString(XGetResourceClass(database,
!     client_name,"geometry",(char *) NULL));
    resource_value=XGetResourceClass(database,client_name,"gravity",
      (char *) "Center");
    resource_info->gravity=(GravityType) ParseMagickOption(MagickGravityOptions,
--- 3482,3489 ----
    resource_value=XGetResourceClass(database,client_name,"gammaCorrect",
      (char *) "True");
    resource_info->gamma_correct=IsMagickTrue(resource_value);
!   resource_info->image_geometry=XGetResourceClass(database,client_name,
!     "geometry",(char *) NULL);
    resource_value=XGetResourceClass(database,client_name,"gravity",
      (char *) "Center");
    resource_info->gravity=(GravityType) ParseMagickOption(MagickGravityOptions,
***************
*** 3504,3511 ****
      (char *) NULL);
    resource_info->matte_color=XGetResourceInstance(database,client_name,
      "mattecolor",(char *) NULL);
!   resource_info->name=ConstantString(XGetResourceClass(database,client_name,
!     "name",(char *) NULL));
    resource_info->pen_colors[0]=XGetResourceClass(database,client_name,"pen1",
      (char *) "black");
    resource_info->pen_colors[1]=XGetResourceClass(database,client_name,"pen2",
--- 3504,3511 ----
      (char *) NULL);
    resource_info->matte_color=XGetResourceInstance(database,client_name,
      "mattecolor",(char *) NULL);
!   resource_info->name=XGetResourceClass(database,client_name,"name",
!     (char *) NULL);
    resource_info->pen_colors[0]=XGetResourceClass(database,client_name,"pen1",
      (char *) "black");
    resource_info->pen_colors[1]=XGetResourceClass(database,client_name,"pen2",
3f719

Re: segfault in import

Post by 3f719 »

I tried your patch(then make clean; make), but I still get the same segfault.



gdb ./utilities/.libs/import
GNU gdb 6.8-debian
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 "x86_64-linux-gnu"...
(gdb) run
Starting program: /home/avova/myhome/downloads/ImageMagick-6.4.8-2/utilities/.libs/import
[Thread debugging using libthread_db enabled]
[New Thread 0x7f471278f720 (LWP 9740)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f471278f720 (LWP 9740)]
0x00007f470fc44a23 in free () from /lib/libc.so.6
(gdb) bt
#0 0x00007f470fc44a23 in free () from /lib/libc.so.6
#1 0x00007f471226235f in RelinquishMagickMemory ()
from /usr/lib/libMagickCore.so.1
#2 0x00007f47122e5fd5 in XDestroyResourceInfo ()
from /usr/lib/libMagickCore.so.1
#3 0x00007f4711eee3ff in ImportImageCommand ()
from /usr/lib/libMagickWand.so.1
#4 0x0000000000400e0c in main (argc=1, argv=0x7fff1a7b5e98)
at utilities/import.c:122
(gdb)
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: segfault in import

Post by magick »

The backtrace looks like you are attempting to run a new version of the ImageMagick import program but loading an older ImageMagick MagickCore library in /usr/lib. Try this command and see if it makes a difference
  • cd ImageMagick-6.4.8-3
    utilities/import -window root image.png
That command should pick up the patched library code in the ImageMagick-6.4.8-3 folder.
3f719

Re: segfault in import

Post by 3f719 »

cd ImageMagick-6.4.8-2/
avova@t61:ImageMagick-6.4.8-2$ utilities/import -window root image.png
Segmentation fault
3f719

Re: segfault in import

Post by 3f719 »

Here is what I did:

1) removed all imagemagick related packages from my machine
2) ./configure; make clean ; make; make install (with your patch)
3) when running "import" I get:
import
import: error while loading shared libraries: libMagickCore.so.1: cannot open shared object file: No such file or directory
so ln -s /usr/local/lib/libMagickCore.so.1 /usr/lib/libMagickCore.so.1
(I guess there is a bug somewhere in the configure script?)
4)
import
import: error while loading shared libraries: libMagickWand.so.1: cannot open shared object file: No such file or directory
so ln -s /usr/local/lib/libMagickWand.so.1 /usr/lib/libMagickWand.so.1 as root...

5) Still segfault, but it looks slightly different now:
gdb import
GNU gdb 6.8-debian
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 "x86_64-linux-gnu"...
(gdb) run
Starting program: /usr/local/bin/import
[Thread debugging using libthread_db enabled]
[New Thread 0x7f7324ad4720 (LWP 8137)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f7324ad4720 (LWP 8137)]
0x00007f7321f88a23 in free () from /lib/libc.so.6
(gdb) bt
#0 0x00007f7321f88a23 in free () from /lib/libc.so.6
#1 0x00007f73245a401f in RelinquishMagickMemory (memory=0x62a520)
at magick/memory.c:656
#2 0x00007f7324628ae5 in XDestroyResourceInfo (resource_info=0x7fff2caf8c90)
at magick/xwindow.c:1805
#3 0x00007f73242327f3 in ImportImageCommand (image_info=0x60baf0, argc=1,
argv=0x605360, wand_unused_metadata=<value optimized out>,
exception=0x602050) at wand/import.c:1263
#4 0x0000000000400e0c in main (argc=1, argv=0x7fff2cafa258)
at utilities/import.c:122
(gdb)
Last edited by 3f719 on 2008-12-30T11:08:34-07:00, edited 1 time in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: segfault in import

Post by magick »

Unfortunately we cannot reproduce this bug. Until we get additional information to help us debug, a solution is pending.
3f719

Re: segfault in import

Post by 3f719 »

Weird, I did "make uninstall" and tried ImageMagick-6.0.6.

Same crash:
gdb --args import -window root image.png
GNU gdb 6.8-debian
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 "x86_64-linux-gnu"...
(gdb) run
Starting program: /usr/local/bin/import -window root image.png
[Thread debugging using libthread_db enabled]
[New Thread 0x7f39009fd6e0 (LWP 15198)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f39009fd6e0 (LWP 15198)]
0x00007f38fe297a23 in free () from /lib/libc.so.6
(gdb) bt
#0 0x00007f38fe297a23 in free () from /lib/libc.so.6
#1 0x00007f39003c8b0e in RelinquishMagickMemory (memory=0x62b120)
at memory.c:550
#2 0x00007f3900428375 in XDestroyResourceInfo (resource_info=0x7fff08a20df0)
at xwindow.c:1791
#3 0x00007f39003bca14 in ImportImageCommand (image_info=0x620790, argc=4,
argv=0x6072c0, metadata=<value optimized out>, exception=0x7fff08a22030)
at import.c:1186
#4 0x0000000000400ccf in main (argc=4, argv=0x7fff08a22158) at import.c:110
(gdb)
mkoppanen
Posts: 309
Joined: 2007-06-09T07:06:32-07:00

Re: segfault in import

Post by mkoppanen »

so ln -s /usr/local/lib/libMagickCore.so.1 /usr/lib/libMagickCore.so.1
(I guess there is a bug somewhere in the configure script?)
This sounds more like you don't have /usr/local/lib in your ld.so.conf.

You can try something like:

Code: Select all

echo "/usr/local/lib" > /etc/ld.so.conf.d/usr-local.conf
ldconfig
I tested with following version:

Version: ImageMagick 6.4.2 08/22/08 Q16 http://www.imagemagick.org
Unable to reproduce this issue.
Mikko Koppanen
My blog: http://valokuva.org
broucaries
Posts: 467
Joined: 2008-12-21T11:51:10-07:00

Re: segfault in import

Post by broucaries »

Any news?

Regards
3f719

Re: segfault in import

Post by 3f719 »

Here is the news:

I created a new user account and started "xinit -- :1". import works perfectly.


But it still segfaults under my main user.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: segfault in import

Post by magick »

As stated we cannot reproduce the problem. It would be helpful if you downloaded the latest ImageMagick release, 6.4.8-5 from ftp://ftp.imagemagick.org/pub/ImageMagick, and produced a stack trace with line numbers. That may provide us with enough information to debug the problem remotely.
3f719

Re: segfault in import

Post by 3f719 »

well, just now I downloaded the latest version ImageMagick-6.4.8-3 and it does not segfault anymore. Hooray!
Post Reply