Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

SIGSEGV (0xb) - libgs.so #37

Open
jtyreman opened this issue Nov 21, 2014 · 13 comments
Open

SIGSEGV (0xb) - libgs.so #37

jtyreman opened this issue Nov 21, 2014 · 13 comments
Labels

Comments

@jtyreman
Copy link

using the following code:

    Ghostscript gs = Ghostscript.getInstance();

    try {
        synchronized (gs) {
            String[] gsArgs = new String[9];
            gsArgs[0] = "-psconv";
            gsArgs[1] = "-dNOPAUSE";
            gsArgs[2] = "-dBATCH";
            gsArgs[3] = "-dSAFER";
            gsArgs[4] = "-dAutoRotatePages=/None";
            gsArgs[5] = "-sDEVICE=ps2write";
            gsArgs[6] = "-sOutputFile=" + outputPath;
            gsArgs[7] = "-f";
            gsArgs[8] = pdfFile;

            gs.initialize(gsArgs);
            gs.exit();
        }
        //delete pdf as we no longer need this.
        pdf.delete();


    } catch (GhostscriptException e) {
        // TODO Auto-generated catch block
        System.out.println("Error 1 = " + e.getMessage());
    } finally {

        //delete interpreter instance (safer)
        try {
            Ghostscript.deleteInstance();
        } catch (GhostscriptException e) {
            //nothing
        }
        return outputPath;
    }

Causing a SIGSEGV (0xb) error

any suggestions as to why this may be?

Thanks

@zippy1978
Copy link
Owner

Hi,

It seems to be related to your Ghostscript installation.
Did you try to achieve the same operation with the GS command line ?

Regards,
Gilles

@lucguinchard
Copy link

Hello,

I have the same problem, using the example code from Ghost4J project home page.

My program crashes with the following message. If needed I can provide more stacktrace output.


# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f6d75a9e9d8, pid=8818, tid=140109663655680
#
# JRE version: OpenJDK Runtime Environment (8.0_72-b15) (build 1.8.0_72-b15)
# Java VM: OpenJDK 64-Bit Server VM (25.72-b15 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libgs.so.9.14+0x1ae9d8]
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c #unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/luc/Documents/Java Project/AMGlassfish-root/BackFishManager/hs_err_pid8818.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.

  • I miss perhaps a library.
  • ps2pdf command is working without any problem. So I suppose my ghostscript setup is fine.

Any help would be appreciated.
Thanks,

Luc

@4F2E4A2E
Copy link
Collaborator

We are going to need more info on this in order to reproduce, which OS (the version matters) and which GS are you using? How are you running the code from the first comment?

@lucguinchard
Copy link

Here is a Maven project. (testGS.zip)
I tested the execution of the program on two systems:

  • Mageia 5 (GS 9.14)
  • Centos 6.5 (GS 8.7)

The problem is similar on both systems.
Thanks,

@4F2E4A2E
Copy link
Collaborator

Hey there, i am about to run your code, please upload fichier.ps, thanks.

@lucguinchard
Copy link

Hey :)
Since I have been testing some PS files pass, but not the other . In the zip Imprimante virtuel.zip, there are two files:

  • fichierOK.ps (Good file)
  • fichierKO.ps (Bad file)

@4F2E4A2E
Copy link
Collaborator

There is alot of stuff wrong with your project, but since they are related to maven and java standards, i am going to skip that.
i think i am able to reproduce that error on ubuntu with your fichierKO.ps file, which i think is corrupt, never the less it should lead to an total crash in the jvm since gs native command can convert it to pdf.

  1. install ghostscript on ubuntu and than create a symlinc like that: sudo ln -s /usr/lib/libgs.so.9 /usr/lib/libgs.so
  2. download the testGhost4jIssue37.zip project, unzip it, than run "mvn test"
  3. the juni ttest will try to convert every ps file inside the src/test/resources/test-data folder

As you can see in the log fichierOK.ps is beeing converted just fine, but as assumed fichierKO.ps is not:
testGhost4jIssue37.zip

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running TestPsTopdf
PDF creation successful, here the file path: '/home/eduard/testGhost4jIssue37/src/test/resources/test-results/fichierOK.pdf'.
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f1ff2a95717, pid=16591, tid=139775577265920
#
# JRE version: OpenJDK Runtime Environment (7.0_95) (build 1.7.0_95-b00)
# Java VM: OpenJDK 64-Bit Server VM (24.95-b01 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea 2.6.4
# Distribution: Ubuntu 14.04.3 LTS, package 7u95-2.6.4-0ubuntu0.14.04.1
# Problematic frame:
# C  [libgs.so+0x190717]
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/eduard/testGhost4jIssue37/hs_err_pid16591.log
#
# If you would like to submit a bug report, please include
# instructions on how to reproduce the bug and visit:
#   http://icedtea.classpath.org/bugzilla
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Aborted (core dumped)

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.211s
[INFO] Finished at: Sat Feb 13 23:07:26 CET 2016
[INFO] Final Memory: 16M/191M
[INFO] ------------------------------------------------------------------------

So i am assuming your .ps file is broken, it has more then 7K lines in it, never the less, i was not able to find a way to validate postscript files, so what i did is to basically try to convert it using gs natively
Here the output converting the fichierOK.ps file using gs natively:

eduard@ubuntu:~$ gs   -o output.pdf   -sDEVICE=pdfwrite   -dPDFSETTINGS=/prepress   -dHaveTrueTypes=true   -dEmbedAllFonts=true   -dSubsetFonts=false   -c ".setpdfwrite <</NeverEmbed [ ]>> setdistillerparams"   -f /home/eduard/testGhost4jIssue37/src/test/resources/test-data/fichierOK.ps
GPL Ghostscript 9.10 (2013-08-30)
Copyright (C) 2013 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.

Here the output converting the fichierKO.ps file using gs natively:

eduard@ubuntu:~$ gs   -o output.pdf   -sDEVICE=pdfwrite   -dPDFSETTINGS=/prepress   -dHaveTrueTypes=true   -dEmbedAllFonts=true   -dSubsetFonts=false   -c ".setpdfwrite <</NeverEmbed [ ]>> setdistillerparams"   -f /home/eduard/testGhost4jIssue37/src/test/resources/test-data/fichierKO.ps
GPL Ghostscript 9.10 (2013-08-30)
Copyright (C) 2013 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading NimbusMonL-Regu font from /usr/share/fonts/type1/gsfonts/n022003l.pfb... 4365672 2758088 1994864 639743 1 done.
%%[ ProductName: GPL Ghostscript ]%%
%%[Page: 1]%%
%%[Page: 2]%%
%%[LastPage]%%
eduard@ubuntu:~$ 

@zippy1978 gs is not crashing, though the ps file is corrupt we should find a way in catching this fatal error. Should this be further investigated or do you have enough information for now?

P.s.: results and jvm crash log are inside the zip file.

cheers

@lucguinchard
Copy link

Thank you for your participation.

The solution I have adopted (also in first zip 'testGS.zip') is:
I use the method ps2pdf

Runtime runtime = Runtime.getRuntime();
runtime.exec(new String[] { "ps2pdf", input.getAbsolutePath(), output.getAbsolutePath()} );

I also think it will be that the JVM does not crashing during the run.

@4F2E4A2E
Copy link
Collaborator

You are welcome.
Well since you may have solved it with ps2pdf we can close this ticket right?

Am 26.02.2016 um 18:47 schrieb lucguinchard notifications@github.com:

Thank you for your participation.

The solution I have adopted (also in first zip 'testGS.zip') is:
I use the method ps2pdf

Runtime runtime = Runtime.getRuntime();
runtime.exec(new String[] { "ps2pdf", input.getAbsolutePath(), output.getAbsolutePath()} );
I also think it will be that the JVM does not crashing during the run.


Reply to this email directly or view it on GitHub.

@lucguinchard
Copy link

Hey,
I'm sorry, the workaround does not resolve the application bug. It'll be good that it does not crash the JVM.
I try to come back with more information.
Thanks,

@zippy1978
Copy link
Owner

Hi,

Could you tell me which version of Ghost4J is used for your test ?

For the native GS API / Java interaction, Ghost4J uses JNA. when a crash like this occurs, it's probably due to JNA.

The master branch uses a more recent version of JNA, did you use this one (1.0.1-SNAPSHOT) or the 1.0.0 version ?

Regards

@zippy1978 zippy1978 added the bug label Feb 29, 2016
@4F2E4A2E
Copy link
Collaborator

Hi there!

This error can be reproduced using GS Version 9 and Ghost4J Version 1.0.0 as you can see in this example project created: testGhost4jIssue37.zip

@lucguinchard
Copy link

Hello everyone,

I did a test today.
I have the error:

org.ghost4j.converter.ConverterException: org.ghost4j.GhostscriptException: Cannot initialize Ghostscript interpreter. Error code is -100
	at org.ghost4j.converter.PDFConverter.run(PDFConverter.java:251)
	at org.ghost4j.converter.AbstractRemoteConverter.convert(AbstractRemoteConverter.java:85)
	at fr.amtrust.amtrustcommonghost4j.PSToPDF.Go(PSToPDF.java:32)
	at github.issue37.UnitTest.hello(UnitTest.java:46)
	at github.issue37.UnitTest.main(UnitTest.java:60)
Caused by: org.ghost4j.GhostscriptException: Cannot initialize Ghostscript interpreter. Error code is -100
	at org.ghost4j.Ghostscript.initialize(Ghostscript.java:365)
	at org.ghost4j.converter.PDFConverter.run(PDFConverter.java:231)

But the JVM is not crashed. The exception thrown is ConverterException.

this issue may be closed.

Luc

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants