Tested with commit 4fc4b84 "Bug 694160: Prevent malicious code being injected into the system.", but this was initially seen with an earlier commit (5671fc9) C:\Artifex\agit\ghostpdl\gs>bin\gswin32c -o x.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -c "<< /ProcessColorModel /DeviceGray /ColorConversionStrategy /Gray >> setdistillerparams" -f before.pdf .\base\gsicc_manage.c:1050: gsicc_open_search(): Could not find 0♫?☻?☺ | .\base\gsicc_manage.c:1651: gsicc_set_device_profile(): cannot find device profile If I remove the -dPDFSETTINGS=/ebook then the garbage printed from the first message changes to: .\base\gsicc_manage.c:1084: gsicc_open_search(): Could not find ?S?☻?☺ and changing the PDFSETTINGS to /screen makes it different to wither case Note that repeated runs are consistent. This is probably a UMR.
I'm not sure this is minor -- If I run: bin\gswin32c -sDEVICE=pdfwrite -o x.pdf -c "<< /ColorConversionStrategy /Gray >> setdistillerparams " -f before.pdf It results in: GPL Ghostscript GIT PRERELEASE 9.15 (2014-03-25) Copyright (C) 2014 Artifex Software, Inc. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details. Processing pages 1 through 1. Page 1 Loading NimbusRomNo9L-Regu font from %rom%Resource/Font/NimbusRomNo9L-Regu... 4049288 2572257 2206264 895341 3 done. Loading NimbusSanL-Regu font from %rom%Resource/Font/NimbusSanL-Regu... 4066016 2625268 2226364 915697 3 done. Loading NimbusMonL-Regu font from %rom%Resource/Font/NimbusMonL-Regu... 4082744 2691984 2387164 1069013 3 done. .\base\gsicc_manage.c:1084: gsicc_open_search(): Could not find ???☻?☺ | .\base\gsicc_manage.c:1685: gsicc_set_device_profile(): cannot find device profile Unrecoverable error: undefined in .systemexec.uninstallpagedeviceserverdict Operand stack: --nostringval-- begin
(In reply to Ray Johnston from comment #1) > I'm not sure this is minor -- > > If I run: > bin\gswin32c -sDEVICE=pdfwrite -o x.pdf -c "<< /ColorConversionStrategy > /Gray >> setdistillerparams " -f before.pdf > > It results in: > > GPL Ghostscript GIT PRERELEASE 9.15 (2014-03-25) > Copyright (C) 2014 Artifex Software, Inc. All rights reserved. > This software comes with NO WARRANTY: see the file PUBLIC for details. > Processing pages 1 through 1. > Page 1 > Loading NimbusRomNo9L-Regu font from > %rom%Resource/Font/NimbusRomNo9L-Regu... 4049288 2572257 2206264 895341 3 > done. > Loading NimbusSanL-Regu font from %rom%Resource/Font/NimbusSanL-Regu... > 4066016 2625268 2226364 915697 3 done. > Loading NimbusMonL-Regu font from %rom%Resource/Font/NimbusMonL-Regu... > 4082744 2691984 2387164 1069013 3 done. > .\base\gsicc_manage.c:1084: gsicc_open_search(): Could not find ???☻?☺ > | .\base\gsicc_manage.c:1685: gsicc_set_device_profile(): cannot find device > profile > Unrecoverable error: undefined in .systemexec.uninstallpagedeviceserverdict > Operand stack: > --nostringval-- begin I don't get the corrupted text in gsicc_open_search on a 32-bit build on Windows 7, using either a debug or release build. The error seems to be due to the patch in bug #694160. Somehwo this patch is causing 'quit' to fail (so -o doesn't work properly) and it also seems to be causing this error. If I revert the patch described in that bug report, the error goes away. I'd put this back to unconfirmed if I could, because I don't see the corrupted ICC message, and the error is due to something other than pdfwrite.
For me, using commit a7e8f7592a9861f83dbb94b8b545961caca864ce I do not get any errors, nor any warnings, nor any corrupted strings. I tested using both release and debug 32-bit builds on Windows 7 using the command line given in comment 1. Re-assigning to Ray to see if he can still reproduce this with the fix in the commit above.
This is caused by the gs_setpd.ps logic having a dictionary that has the OutputICCProfile pointing to dev->icc_struct->device_profile[0]->name First, this seems a bit wrong, because the 'name' is allocated in non-GC memory, but when ColorConversionStrategy distillerparam is set, it does a rc_decrement on the pdev->icc_struct which frees the entire structure, among those the 'name'. A partial fix is to add the OutputICCProfile to the list of .dynamicppkeys in gs_setpd.ps so that the string will always be updated and the dictionary won't have a stale pointer. I guess the GC doesn't really care about where t_string objects point to, so this may be enough. The change passes regression testing (since I don't think we ever muck with ColorConversionStrategy)
It's a bit arcane, but I get *really* bad results, including a segfault with this command line: gswin32c -q -sDEVICE=pdfwrite -o x.pdf -c "<< /ProcessColorModel /DeviceGray >> setpagedevice << /ColorConversionStrategy /Gray >> setdistillerparams << /EndPage { currentpagedevice dup /OutputICCProfile get (OutputICCProfile: ) print = /ProcessColorModel get (ProcessColorModel: ) print = flush exch pop 2 ne } >> setpagedevice" -f before.pdf -c "currentpagedevice dup /OutputICCProfile get (After OutputICCProfile: ) print = /ProcessColorModel get (After ProcessColorModel: ) print = flush " gives: OutputICCProfile: (? ☻?☺ |☺ ☺ ProcessColorModel: DeviceGray OutputICCProfile: ??OutputICCProfile: ??OutputICCProfile: h? ☻?☺ .\base\gsicc_manage.c:1084: gsicc_open_search(): Could not find h? ☻?☺ | .\base\gsicc_manage.c:1685: gsicc_set_device_profile(): cannot find device profile ?Error: /rangecheck in .installpagedevice Operand stack: --nostringval-- --dict:200/208(ro)(L)-- --nostringval-- <--- SNIP ---> GPL Ghostscript GIT PRERELEASE 9.15: Unrecoverable error, exit code 1
Actually, the problem with the segfault is probably separate. Ignore comment 6 as I will open a new bug, since this: debugbin/gswin32c -Z@\$\? -q -sDEVICE=pdfwrite -o x.pdf -c "<< /ProcessColorModel /DeviceGray >> setpagedevice" -f examples/annots.pdf dies with: Error: /rangecheck in .installpagedevice Operand stack: --nostringval-- --dict:200/208(ro)(L)-- --nostringval-- <--- SNIP ---> GPL Ghostscript GIT PRERELEASE 9.15: Unrecoverable error, exit code 1 GPL Ghostscript GIT PRERELEASE 9.15: .\psi\ilocate.c(597): Reference to free object 0x2190a10(168), in chunk 0x2189b08! while validating chunk 0x218a2e8 (0x21c9fa0..0x21d0e90, 0x21d0e90..0x21d0e90..0x21d0e90) GPL Ghostscript GIT PRERELEASE 9.15: .\psi\ilocate.c(258): while validating memory 0x226f980, space 8, level -1
While this is still somewhat questionable -- having strings in PS dicts point to areas that are not in GC memory -- the problem of using a stale pointer is solved, so closing this bug. Bug 695439 was opened to track the problem stumbled over in Comment 7.
I'm not sure this bug is resolved. I have just installed the latest Ghostscript downloaded from the website, and ran the following command: C:\>"C:\Program Files\gs\gs9.15\bin\gswin64c.exe" -dQUIET -dBATCH -dNOPAUSE -dSAFER -dMaxSubsetPct=100 -dPDFSETTINGS=/ebook -sDEVICE=pdfwrite -sOutputFile=outputfile.pdf input.pdf .\base\gsicc_manage.c:1084: gsicc_open_search(): Could not find `N?|.\base\gsicc_manage.c:1685: gsicc_set_device_profile(): cannot find device profile Changing the filename changes what could not be found. (I originally found it with a different filename.)
(In reply to Martin Bonner from comment #9) > I'm not sure this bug is resolved. I have just installed the latest > Ghostscript downloaded from the website, and ran the following command: 1. Changing to -dPDFSETTINGS=/printer works (which is handy, because that's what I want). 2. I'm running on 64-bit Windows 8.1
I believe it *is* now fixed (finally!) by this commit: http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=69a6dc94 from last October - so it has not been in an official release yet. As mentioned in the commit message, the warning you encountered was hard to reproduce reliably, which probably accounts for why it went away when Ray fixed the real (but subtly different) issue he spotted above.
(In reply to Chris Liddell from comment #11) > I believe it *is* now fixed (finally!) by this commit: > http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=69a6dc94 > > from last October - so it has not been in an official release yet. Aah! Thanks. That sort of bug is a *swine* to find. Well done that man!