Bug 692251 - SegFault on every PDF file when compiled with '--disable-compile-inits'
Summary: SegFault on every PDF file when compiled with '--disable-compile-inits'
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Color (show other bugs)
Version: master
Hardware: PC Linux
: P1 normal
Assignee: Alex Cherepanov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-03 05:46 UTC by Vladimir Lomov
Modified: 2011-06-28 06:38 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments
Example PS file (generated by dvips) (25.99 KB, application/postscript)
2011-06-03 05:46 UTC, Vladimir Lomov
Details
Valgrind output (245.53 KB, text/x-log)
2011-06-03 05:46 UTC, Vladimir Lomov
Details
strace output (197.12 KB, text/x-log)
2011-06-03 05:47 UTC, Vladimir Lomov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Lomov 2011-06-03 05:46:11 UTC
Created attachment 7559 [details]
Example PS file (generated by dvips)

Hi.
I'm testing gs from GIT repo compiling it on my system:
Archlinux, x86_64, gcc 4.6.0 20110513

The simple
$ gs --version
works fine
but a run gs with option gives segfault:
$ gs -sDEVICE=pdfwrite -sOutputFile=ex1.pdf ex1.ps
<output>
GPL Ghostscript GIT PRERELEASE 9.03 (2011-03-30)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
sfopen: gs_parse_file_name failed.
sfopen: gs_parse_file_name failed.
  ./base/gsicc_manage.c:894: gsicc_open_search(): Could not find default_rgb.icc 
| ./base/gsicc_manage.c:1137: gsicc_set_device_profile(): cannot find device profile
Segmentation fault
</output>

I tried version without stripping symbols and get following under gdb, valgrind and strace (see attached files). Run commands:

$ valgrind -v --show-reachable=yes --leak-check=full gs -sDEVICE=pdfwrite -sOutputFile=ex1.pdf ex1.ps
$ strace -F -v gs -sDEVICE=pdfwrite -sOutputFile=ex1.pdf ex1.ps > strace-gs.log 2>&1
$ gdb gs

GNU gdb (GDB) 7.2
Copyright (C) 2010 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-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/gs...(no debugging symbols found)...done.
(gdb) run -sDEVICE=pdfwrite -sOutputFile=ex1.pdf ex1.ps
Starting program: /usr/bin/gs -sDEVICE=pdfwrite -sOutputFile=ex1.pdf ex1.ps
[Thread debugging using libthread_db enabled]
GPL Ghostscript GIT PRERELEASE 9.03 (2011-03-30)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
sfopen: gs_parse_file_name failed.
sfopen: gs_parse_file_name failed.
  ./base/gsicc_manage.c:894: gsicc_open_search(): Could not find default_rgb.icc 
| ./base/gsicc_manage.c:1137: gsicc_set_device_profile(): cannot find device profile

Program received signal SIGSEGV, Segmentation fault.
0x000000000055e4d6 in gx_remap_ICC ()
(gdb) backtrace
#0  0x000000000055e4d6 in gx_remap_ICC ()
#1  0x00000000007ae10c in gx_remap_color ()
#2  0x000000000079ba58 in gs_fillpage ()
#3  0x00000000004c9f68 in interp ()
#4  0x00000000004caac3 in gs_interpret ()
#5  0x00000000004bfa63 in gs_main_run_string_end ()
#6  0x00000000004c07cb in run_string ()
#7  0x00000000004c0931 in runarg ()
#8  0x00000000004c27af in gs_main_init_with_args ()
#9  0x0000000000457ae4 in main ()
(gdb)

P.S. GS was compiled using this options:
              --prefix=/usr       \
              --enable-dynamic    \
              --with-ijs          \
              --with-jbig2dec     \
              --with-omni         \
              --with-x            \
              --enable-fontconfig \
              --enable-dbus       \
              --enable-freetype   \
              --with-libpaper     \
              --with-drivers=ALL  \
              --with-fontpath=/usr/share/fonts/Type1:/usr/share/fonts \
              --enable-debug \
              --disable-compile-inits
Details in
https://github.com/vp1981/pkgbuild/blob/master/ghostscript/PKGBUILD

---
WBR, VLadimir Lomov
Comment 1 Vladimir Lomov 2011-06-03 05:46:51 UTC
Created attachment 7560 [details]
Valgrind output
Comment 2 Vladimir Lomov 2011-06-03 05:47:17 UTC
Created attachment 7561 [details]
strace output
Comment 3 Alex Cherepanov 2011-06-16 20:18:08 UTC
The problem first occurred in the following commit.

commit 1787ce3393956701e6241b8efc6f575887c3f5c1
Author: Michael Vrhel <michael.vrhel@artifex.com>
Date:   Sun May 15 15:50:40 2011 -0700

Change in device ICC profile handling
Comment 4 Michael Vrhel 2011-06-27 05:30:10 UTC
This should be fixed with 

http://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=f4e1d4b280f6e6ff73d630e2b103a1a6b50c03d9

Where I have forced the device icc directory to be set the the icc manager directory during the device start up prior to actually getting the profile.
Comment 5 Vladimir Lomov 2011-06-28 04:54:46 UTC
(In reply to comment #4)
> This should be fixed with 
> 
> http://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=f4e1d4b280f6e6ff73d630e2b103a1a6b50c03d9
> 
> Where I have forced the device icc directory to be set the the icc manager
> directory during the device start up prior to actually getting the profile.

Sorry, I can't check it right now due to this
http://bugs.ghostscript.com/show_bug.cgi?id=692306
Comment 6 Henry Stiles 2011-06-28 06:38:54 UTC
Hello Vladimir, it gets confusing allowing all users to change the status field.  We have now restricted this to the Artifex Staff, if you have more problems you can create a new bug or add comments.  Thanks.