Bug 695979

Summary: GhostPDL - PCL6 throwing Bus error(coredump)
Product: GhostPCL Reporter: MG <gajula.mohan>
Component: PDF WriterAssignee: Chris Liddell (chrisl) <chris.liddell>
Status: RESOLVED INVALID    
Severity: normal CC: chris.liddell, gajula.mohan, htl10, robin.watts
Priority: P4    
Version: 9.16   
Hardware: HP   
OS: HP-UX   
Customer: Word Size: ---
Attachments: pcl file (owl.plc)
DEMO1.PCL

Description MG 2015-05-07 14:05:07 UTC
Hello Support Team,

I am trying to convert a simple PCL file to PDF using pcl6, and it gives me “Bus error(coredump)”. When I try to run the pcl6 alone, it gives me regular usage, options, version, Build date, Devices. However when trying to convert pcl to pdf, it gives me bus error. Any support will really help me.

GhostPDL Version: 9.16
Environment: HP-UX 11.31 ia64

I have compiled GhostPDL after running the configure, and then make. 

Here is the pcl file content: DEMO.PCL
^[(s1p22v0s0b4197T
^[*p183x99Y TEST HEADER LINE ^[(s11V
^[*p183x155Y BODY LINE

Command line: 
/ghostPDL/ghostpdl-9.16/main/obj/pcl6 -sOutputFile=out.pdf  -sDEVICE=pdfwrite DEMO.PCL 
Bus error(coredump)



Thanks
Comment 1 Hin-Tak Leung 2015-05-07 15:58:53 UTC
(In reply to MG from comment #0)
> Hello Support Team,
> 
> I am trying to convert a simple PCL file to PDF using pcl6, and it gives me
> “Bus error(coredump)”. When I try to run the pcl6 alone, it gives me regular
> usage, options, version, Build date, Devices. However when trying to convert
> pcl to pdf, it gives me bus error. Any support will really help me.
> 
> GhostPDL Version: 9.16
> Environment: HP-UX 11.31 ia64
> 
> I have compiled GhostPDL after running the configure, and then make. 
> 
> Here is the pcl file content: DEMO.PCL
> ^[(s1p22v0s0b4197T
> ^[*p183x99Y TEST HEADER LINE ^[(s11V
> ^[*p183x155Y BODY LINE
> 
> Command line: 
> /ghostPDL/ghostpdl-9.16/main/obj/pcl6 -sOutputFile=out.pdf 
> -sDEVICE=pdfwrite DEMO.PCL 
> Bus error(coredump)
> 
> 
> 
> Thanks

I don't have 9.16 handy, but 29cc06b and 9.15 on x86_64 linux both finishes okay. BTW, your report had two problems:

- you are missing a "-dNOPAUSE" in the command line. (or you should use "-o",
which is equivalent to "-dNOPAUSE -sOutputFile=" also).

- "^[" really means 0x1b (<ESC)>)

I suggest if you have alternative OSes which are not ia64 or different compiler (you are using HP's compiler, right), try gcc? You might have a architecture/os specific issue.
Comment 2 MG 2015-05-07 21:59:34 UTC
I tried compiling using GCC and also CC. Both are throwing the same error. Ofcourse, I have compiled it on Windows and the same PCL is getting converted to PDF in windows using pcl6.exe. 


Can you please let us know what would be the problem. 

Right now, for testing purpose, I can perform it on Windows. However, in reality I have to make it work on HP-UX. Please help. Thanks
Comment 3 Ken Sharp 2015-05-08 00:43:24 UTC
(In reply to MG from comment #2)
> I tried compiling using GCC and also CC. Both are throwing the same error.
> Ofcourse, I have compiled it on Windows and the same PCL is getting
> converted to PDF in windows using pcl6.exe. 
> 
> 
> Can you please let us know what would be the problem. 
> 
> Right now, for testing purpose, I can perform it on Windows. However, in
> reality I have to make it work on HP-UX. Please help. Thanks

You need to attach an example file before anyone will look at this.

However, since the problem does not exhibit on Windows, it almost certainly will not exhibit on any system available to us. If you can reproduce the problem on Windows (32 or 64 bit) or Linux, then we can investigate it.

Otherwise you are on your own. At least a seg fault should be easy to debug.
Comment 4 Robin Watts 2015-05-08 00:58:53 UTC
(In reply to MG from comment #2)
> Can you please let us know what would be the problem. 

Just to double check, are you either a supported customer, or a commercial customer of Artifex? I don't recognise con-way.com as either.

As Ken says, Ghostscript/PCL are supplied as standard with no warranty or support. If you want us to help you, then you should obtain a support contract from sales@artifex.com, and provide us with a test file.
Comment 5 MG 2015-05-08 09:11:13 UTC
Thanks for the reply. 

Right now, we don't have a support contract with Artifex. Do we know if HP-UX is compatible for GhostPDL library? If so, then we can start fetching a support contract from Artifex. 

Thanks again.
Comment 6 Ken Sharp 2015-05-08 09:17:44 UTC
(In reply to MG from comment #5)
> Thanks for the reply. 
> 
> Right now, we don't have a support contract with Artifex. Do we know if
> HP-UX is compatible for GhostPDL library? If so, then we can start fetching
> a support contract from Artifex. 

Ghostscript is cross-platform.

You still have not supplied an example file.
Comment 7 MG 2015-05-08 09:23:53 UTC
Ken - I tried using the owl.pcl that came with the package. 

./ghostpdl-9.16/tools/owl.pcl

Also, I am attaching a sample (DEMO1.PCL) that I am testing with. 


/ghostpdl-9.16/main/obj/pcl6 -sOutputFile=out.pdf  -sDEVICE=pdfwrite owl.pcl
Bus error(coredump)
Comment 8 MG 2015-05-08 09:24:43 UTC
Created attachment 11662 [details]
pcl file (owl.plc)
Comment 9 MG 2015-05-08 09:25:19 UTC
Created attachment 11663 [details]
DEMO1.PCL
Comment 10 Hin-Tak Leung 2015-05-08 09:25:36 UTC
(In reply to Ken Sharp from comment #6)
..
> You still have not supplied an example file.

He had - the test file was inline, in the initial report - you also need to convert the "^[" to 0x1b (<ESC>), but it is otherwise a valid PCL file.

<quote>
Here is the pcl file content: DEMO.PCL
^[(s1p22v0s0b4197T
^[*p183x99Y TEST HEADER LINE ^[(s11V
^[*p183x155Y BODY LINE
</quote>
Comment 11 MG 2015-05-08 09:29:24 UTC
Hin-Tak Leung,

I tried removing the first two lines, and made a PCL file with just one line like this. Still having the same problem. 

^[*p183x155Y ADDRESS LINE 1

Do you want me to send the log that gets generated while running configure and make ? If it helps. 


Thanks guys for helping out.
Comment 12 Hin-Tak Leung 2015-05-08 09:35:35 UTC
(In reply to MG from comment #2)
> I tried compiling using GCC and also CC. Both are throwing the same error.
... 
...
> Right now, for testing purpose, I can perform it on Windows. However, in
> reality I have to make it work on HP-UX. Please help. Thanks

That sounds like a HP-UX/ia64 specific issue. There was at least one HP-UX/Tru64 specific issue in ghostscript from almost a decade about memcpy vs memmove. (Linux's and windows' memcpy can handle overlapping copy, - it is forbidden in the unix spec - and HP-UX/Tru64's cannot). Not too surprised there might be some in ghostpcl also.
Comment 13 Hin-Tak Leung 2015-05-08 09:39:02 UTC
(In reply to MG from comment #11)
...
> Do you want me to send the log that gets generated while running configure
> and make ? If it helps. 

log is no use, but if you actually can generate a core file and have a back trace, that would be useful. Google for 'core file' and 'back trace' and possibly install gdb and read the gdb manual to see how that is done.
Comment 14 Ken Sharp 2015-05-08 09:43:39 UTC
(In reply to Hin-Tak Leung from comment #10)
> (In reply to Ken Sharp from comment #6)
> ..
> > You still have not supplied an example file.
> 
> He had - the test file was inline,

So... not a file then.

Frankly if you don't have something useful to contribute, then please don't
Comment 15 MG 2015-05-08 09:45:10 UTC
(In reply to Hin-Tak Leung from comment #13)
> (In reply to MG from comment #11)
> ...
> > Do you want me to send the log that gets generated while running configure
> > and make ? If it helps. 
> 
> log is no use, but if you actually can generate a core file and have a back
> trace, that would be useful. Google for 'core file' and 'back trace' and
> possibly install gdb and read the gdb manual to see how that is done.


Here is what it shows when I try to look at the core. 

gdb ./exe core
HP gdb 6.1 for HP Itanium (32 or 64 bit) and target HP-UX 11iv2 and 11iv3.
Copyright 1986 - 2009 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 6.1 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.
.../exe: No such file or directory.


warning: Unknown symbols for 'core'; use the 'symbol-file' command.
Core was generated by `pcl6'.
Program terminated with signal 10, Bus error.
BUS_ADRALN - Invalid address alignment. Please refer to the following link that helps in handling unaligned data: http://docs.hp.com/en/7730/newhelp0610/pragmas.htm#pragma-pack-ex3
No object file symbols.
#0  0x4437df0 in <unknown_procedure> ()
(gdb)
Comment 16 Hin-Tak Leung 2015-05-08 09:49:47 UTC
(In reply to MG from comment #15)
... 
> gdb ./exe core
...
> .../exe: No such file or directory.
...

you need to do 

gdb <pcl6binary,fullpath> core

It does not appear that you have used gdb before (and it isn't appropriate
to go into a tutorial here)... I think you need you local sys admin to help you a bit on this.
Comment 17 MG 2015-05-08 09:51:00 UTC
(In reply to Hin-Tak Leung from comment #16)
> (In reply to MG from comment #15)
> ... 
> > gdb ./exe core
> ...
> > .../exe: No such file or directory.
> ...
> 
> you need to do 
> 
> gdb <pcl6binary,fullpath> core
> 
> It does not appear that you have used gdb before (and it isn't appropriate
> to go into a tutorial here)... I think you need you local sys admin to help
> you a bit on this.

That's true. I will have someone from our Unix team to look into it. Thanks.
Comment 18 MG 2015-05-08 10:10:34 UTC
I guess this will help more. 

gdb ghostPDL/ghostpdl-9.16/main/obj/pcl6 -core core
HP gdb 6.1 for HP Itanium (32 or 64 bit) and target HP-UX 11iv2 and 11iv3.
Copyright 1986 - 2009 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 6.1 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.
..
Core was generated by `pcl6'.
Program terminated with signal 10, Bus error.
BUS_ADRALN - Invalid address alignment. Please refer to the following link that helps in handling unaligned data: http://docs.hp.com/en/7730/newhelp0610/pragmas.htm#pragma-pack-ex3
#0  0x4437df0:0 in cmsSetAdaptationStateTHR+0x50 ()

(gdb) bt
#0  0x4437df0:0 in cmsSetAdaptationStateTHR+0x50 ()
#1  0x4439800:0 in cmsCreateMultiprofileTransformTHR+0xe0 ()
#2  0x44399c0:0 in cmsCreateTransformTHR+0x80 ()
#3  0x439cfd0:0 in gscms_get_link+0x1c0 ()
#4  0x4399eb0:0 in gsicc_get_link_profile+0x1010 ()
#5  0x439bd30:0 in gsicc_get_link+0x630 ()
#6  0x438a120:0 in gx_remap_ICC+0x510 ()
#7  0x4873210:0 in gx_remap_DeviceGray+0x150 ()
#8  0x4878fe0:0 in gx_remap_color+0xf0 ()
#9  0x47391e0:0 in gs_fillpage+0x340 ()
#10 0x4739290:0 in gs_erasepage+0x80 ()
#11 0x41bb1e0:0 in pcl_impl_set_device+0x3c0 ()
#12 0x49489b0:0 in pl_set_device+0x80 ()
#13 0x49eb5d0:0 in pl_main_universe_select+0x420 ()
#14 0x49ec880:0 in pl_main_aux+0x7c0 ()
#15 0x49e7030:0 in main+0x30 ()
(gdb)
Comment 19 Hin-Tak Leung 2015-05-08 11:39:24 UTC
(In reply to MG from comment #18)
> I guess this will help more. 
..
> (gdb) bt
> #0  0x4437df0:0 in cmsSetAdaptationStateTHR+0x50 ()
> #1  0x4439800:0 in cmsCreateMultiprofileTransformTHR+0xe0 ()
> #2  0x44399c0:0 in cmsCreateTransformTHR+0x80 ()
..

Yes it does. It is crashing inside the little cms library. little cms (http://www.littlecms.com/) is an external library bundled with ghostscript/ghostpcl since version 9 to provide color management functionality, and a relatively newly added dependency. You may need to contact them for this.

While ghostscript 8 and below worked quite well with the legacy unix systems (and I helped a bit with that), the color management code is a relatively new addition to v9 and there are not many users/testers on older unix systems.
Comment 20 Hin-Tak Leung 2015-05-08 12:02:51 UTC
Another thought - I am not sure to what extent ghostscript's option applies to ghostpcl (the documentation is a bit sparse on this...), but ghostscript has an option -dUseFastColor=true to bypass the newer color management code and goes back to a more v8-like behavior (caveat possible inaccurate colors). Try adding that to the command line and see if it can avoid the crash.

Note that even if that switch avoids the crash, you will likely suffer from inaccurate colors. Testing this way just confirms the issue is in the newer color management code.
Comment 21 Hin-Tak Leung 2015-05-08 12:16:46 UTC
Oh, the gdb back trace would be even more useful if you use a debug build of pcl6 (instead of the default release build). i.e. do "make debug" instead of plain "make", and use the debug binary (main/debugobj/pcl6) instead of the release binary (main/obj/pcl6), and repeat the procedure.
Comment 22 Ray Johnston 2015-05-08 12:25:07 UTC
This is somewhat concerning since Ghostscript also uses lcms2 and we do have
customers on HP-UX as well as at least one free user (Nelson B.) that builds
and tests on a wide variety of platforms (that I think include HP-UX).

The most likely culprit in cmsSetAdaptationStateTHR is the line:

Unfortunately, the stack trace, which identifies cmsSetAdaptationStateTHR+0x50
does not tell us which line is the culprit, either:
       prev = ptr ->AdaptationState;
or
       ptr ->AdaptationState = d;

Unfortunately x86 platforms are (for the most part) very forgiving about
alignment, so either we put trace code in this function to "manually" check
for alignment, or we need access to an HP-UX system that has gcc+gdb (the
latter is preferred).
Comment 23 MG 2015-05-08 13:04:46 UTC
(In reply to Hin-Tak Leung from comment #21)
> Oh, the gdb back trace would be even more useful if you use a debug build of
> pcl6 (instead of the default release build). i.e. do "make debug" instead of
> plain "make", and use the debug binary (main/debugobj/pcl6) instead of the
> release binary (main/obj/pcl6), and repeat the procedure.

I was able to get the debug build and gdb it..


gdb /ghostPDL/ghostpdl-9.16/main/debugobj/pcl6 core
HP gdb 6.1 for HP Itanium (32 or 64 bit) and target HP-UX 11iv2 and 11iv3.
Copyright 1986 - 2009 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 6.1 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.
..
Core was generated by `pcl6'.
Program terminated with signal 10, Bus error.
BUS_ADRALN - Invalid address alignment. Please refer to the following link that helps in handling unaligned data: http://docs.hp.com/en/7730/newhelp0610/pragmas.htm#pragma-pack-ex3
#0  0x4788c00:1 in cmsSetAdaptationStateTHR (ContextID=0x40788fd0, d=-1)
    at ../gs/lcms2/src/cmsxform.c:63
63          prev = ptr ->AdaptationState;
(gdb) bt
#0  0x4788c00:1 in cmsSetAdaptationStateTHR (ContextID=0x40788fd0, d=-1)
    at ../gs/lcms2/src/cmsxform.c:63
#1  0x4790ba0:0 in cmsCreateMultiprofileTransformTHR (ContextID=0x40788fd0,
    hProfiles=0x7fffdd00, nProfiles=2, InputFormat=196618,
    OutputFormat=262170, Intent=1, dwFlags=9216)
    at ../gs/lcms2/src/cmsxform.c:897
#2  0x47910c0:0 in cmsCreateTransformTHR (ContextID=0x40788fd0,
    Input=0x407f3ca8, InputFormat=196618, Output=0x408878b8,
    OutputFormat=262170, Intent=1, dwFlags=9216)
    at ../gs/lcms2/src/cmsxform.c:942
#3  0x465f3d0:0 in gscms_get_link (lcms_srchandle=0x407f3ca8,
    lcms_deshandle=0x408878b8, rendering_params=0x7fffdecc, cmm_flags=0,
    memory=0x40791368) at ../gs/base/gsicc_lcms2.c:570
#4  0x4658020:0 in gsicc_get_link_profile (pis=0x407a0fb0, dev=0x40846a20,
    gs_input_profile=0x407ba120, gs_output_profile=0x4086f6e0,
    rendering_params=0x7fffdecc, memory=0x40791368, devicegraytok=1)
    at ../gs/base/gsicc_cache.c:984
#5  0x4655790:0 in gsicc_get_link (pis=0x407a0fb0, dev_in=0x40846a20,
    pcs_in=0x407a2660, output_colorspace=0x0, rendering_params=0x7fffdecc,
    memory=0x40791368) at ../gs/base/gsicc_cache.c:644
#6  0x462c0c0:0 in gx_remap_ICC (pcc=0x4086c788, pcs=0x407a2660,
    pdc=0x4086c9c8, pis=0x407a0fb0, dev=0x40846a20,
    select=gs_color_select_texture) at ../gs/base/gsicc.c:405
---Type <return> to continue, or q <return> to quit---
#7  0x512cb20:0 in gx_remap_DeviceGray (pc=0x4086c788, pcs=0x407a2660,
    pdc=0x4086c9c8, pis=0x407a0fb0, dev=0x40846a20,
    select=gs_color_select_texture) at ../gs/base/gxcmap.c:785
#8  0x512a670:0 in gx_remap_color (pgs=0x407a0fb0) at ../gs/base/gxcmap.c:560
#9  0x4e5fa00:0 in gs_fillpage (pgs=0x407a0fb0) at ../gs/base/gspaint.c:90
#10 0x4e5f600:0 in gs_erasepage (pgs=0x407a0fb0) at ../gs/base/gspaint.c:66
#11 0x421f600:0 in pcl_impl_set_device (instance=0x4079f480, device=0x40846a20)
    at ../pcl/pctop.c:451
#12 0x5340900:0 in pl_set_device (instance=0x4079f480, device=0x40846a20)
    at ../pl/pltop.c:118
#13 0x54da320:0 in pl_main_universe_select (universe=0x7fffec44,
    err_str=0x7fffeb3c "", pjl_instance=0x40796258,
    desired_implementation=0x405860e0, pti=0x7fffe1b0, params=0x7fffef78)
    at ../pl/plmain.c:793
#14 0x54d7190:0 in pl_main_aux (argc=4, argv=0x7ffff634, disp=0x0)
    at ../pl/plmain.c:412
#15 0x54d82b0:0 in pl_main (argc=4, argv=0x7ffff634) at ../pl/plmain.c:560
#16 0x54d57e0:0 in main (argc=4, argv=0x7ffff634) at ../pl/realmain.c:21
(gdb)
Comment 24 MG 2015-05-08 13:14:29 UTC
(In reply to Hin-Tak Leung from comment #20)
> Another thought - I am not sure to what extent ghostscript's option applies
> to ghostpcl (the documentation is a bit sparse on this...), but ghostscript
> has an option -dUseFastColor=true to bypass the newer color management code
> and goes back to a more v8-like behavior (caveat possible inaccurate
> colors). Try adding that to the command line and see if it can avoid the
> crash.
> 
> Note that even if that switch avoids the crash, you will likely suffer from
> inaccurate colors. Testing this way just confirms the issue is in the newer
> color management code.

Wohoo !! It works :) 

This is what I used now ..

/ghostPDL/ghostpdl-9.16/main/obj/pcl6 -sOutputFile=DEMO1.pdf -dNOPAUSE -sDEVICE=pdfwrite  -dUseFastColor=true DEMO1.PCL
Comment 25 MG 2015-05-08 13:15:46 UTC
Awesome Guys.. Thanks all for your help.. Happy Friday and Have a nice weekend :)
Comment 26 Hin-Tak Leung 2015-05-08 13:21:58 UTC
(In reply to MG from comment #24)
...
> > Note that even if that switch avoids the crash, you will likely suffer from
> > inaccurate colors. Testing this way just confirms the issue is in the newer
> > color management code.
> 
> Wohoo !! It works :) 
...

It isn't quite fixed - it is just a workaround - as I mentioned, you will likely get inaccurate colors (though for PCL input - rather than postscript/pdf - that's not a serious issue).
Comment 27 MG 2015-05-08 13:23:35 UTC
(In reply to Hin-Tak Leung from comment #26)
> (In reply to MG from comment #24)
> ...
> > > Note that even if that switch avoids the crash, you will likely suffer from
> > > inaccurate colors. Testing this way just confirms the issue is in the newer
> > > color management code.
> > 
> > Wohoo !! It works :) 
> ...
> 
> It isn't quite fixed - it is just a workaround - as I mentioned, you will
> likely get inaccurate colors (though for PCL input - rather than
> postscript/pdf - that's not a serious issue).

Output PDF's will be printed onto a Black and White Laser Printer. So we should be good. Thanks
Comment 28 Chris Liddell (chrisl) 2015-05-08 15:05:27 UTC
We had a very similar crash on Solaris/SPARC a while back, the solution/workaround was only applied for that platform.

You could try building thus:

make clean
./configure CFLAGS="-DCMS_PTR_ALIGNMENT=8"
make

And see if the problem still happens.
Comment 29 Chris Liddell (chrisl) 2015-05-12 08:09:56 UTC
No response.....