[Magick-bugs] problem reading GRAY images in 6.2.4

Christophe Beauregard chris.beauregard at ec.gc.ca
Wed Jan 17 10:53:04 CST 2007


In a nutshell, it appears that something (recent) is causing ReadImage on 
GRAY (and possibly other) files to try reading from standard input. The 
attached program (hopefully this list doesn't filter attachments?) 
illustrates the problem:

  cpb at tiny:~/HEAD/mm$ uname -a
  Linux tiny 2.6.18-3-686 #1 SMP Mon Dec 4 16:41:14 UTC 2006 i686 GNU/Linux
  cpb at tiny:~/HEAD/mm$ cat /etc/debian_version
  4.0
  cpb at tiny:~/HEAD/mm/im/misc$ Magick-config --version
  6.2.4
  cpb at tiny:~/HEAD/mm/im/misc$ gcc -o graybug graybug.c -lMagick
  cpb at tiny:~/HEAD/mm/im/misc$ ./graybug graybug-256x256
  loading graybug-256x256
  image dimensions '256x256'
  <ctrl-C> to terminate
  cpb at tiny:~/HEAD/mm/im/misc$ ./graybug graybug-256x256 </dev/null
  loading graybug-256x256
  image dimensions '256x256'
  finished loading image graybug-256x256

An strace shows that it's clearly hanging on a read from stdin (I've 
chopped some extraneous output from this):

  cpb at tiny:~/HEAD/mm/im/misc$ strace ./graybug graybug-256x256      
  write(2, "loading graybug-256x256\n", 24loading graybug-256x256) = 24
  access("graybug-256x256", R_OK)         = 0
  open("graybug-256x256", O_RDONLY)       = 3
  write(2, "image dimensions \'256x256\'\n", 27image dimensions '256x256'
) = 27
  stat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
  gettimeofday({1169052192, 566695}, NULL) = 0
  open("/tmp/magick-XXRogRLP", O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600) = 4
  mmap2(NULL, 249856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 
0) = 0xb7621000
  fstat64(0, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 2), ...}) = 0
  mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 
= 0xb7fac000
  read(0,  <unfinished ...>

And a stack trace from an attached debugger gives:

  #0  0xb7ad9cbe in read () from /lib/tls/libc.so.6
  #1  0xb7a7c9a8 in _IO_file_read () from /lib/tls/libc.so.6
  #2  0xb7a7c3f9 in _IO_file_seek () from /lib/tls/libc.so.6
  #3  0xb7a7e4f8 in _IO_sgetn () from /lib/tls/libc.so.6
  #4  0xb7a72fcf in fread () from /lib/tls/libc.so.6
  #5  0xb7b9615e in ImageToFile () from /usr/lib/libMagick.so.9
  #6  0xb7c4af12 in SetImageInfo () from /usr/lib/libMagick.so.9
  #7  0xb7bc5fd3 in ReadImage () from /usr/lib/libMagick.so.9
  #8  0x080489d4 in main ()

If I change the call from a ReadImage to an explicit read-into-buffer and 
BlobToImage(), it no longer hangs up. Not the most efficient, 
unfortunately:

  cpb at tiny:~/HEAD/mm/im/misc$ diff graybug.c graybug-blob.c
  52c52,58
  <       image = ReadImage( image_info, &exception );
  ---
  >       {
  >               size_t sz = 256*256;
  >               char* blob = calloc(sz,1);
  >               fread(blob,1,sz,in);
  >               image = BlobToImage( image_info, blob, sz, &exception );
  >               free( blob );
  >       }

c.

-- 
Christophe Beauregard <chris.beauregard at ec.gc.ca>
Informatics Specialist, Software
Chief Information Officer Branch, Trenton
Environment Canada
(613) 965-2762
I telework most Tuesday and Thursdays. Please use e-mail on those days.


More information about the Magick-bugs mailing list