

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
2 messages in net.java.dev.jna.users[jna-users] [Ghostscript] Do not unde...| From | Sent On | Attachments |
|---|---|---|
| Cyril Delmas | Mar 3, 2009 12:32 am | |
| Timothy Wall | Mar 3, 2009 3:49 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | [jna-users] [Ghostscript] Do not understand the crash | Actions... |
|---|---|---|
| From: | Cyril Delmas (cyri...@cgin.fr) | |
| Date: | Mar 3, 2009 12:32:56 am | |
| List: | net.java.dev.jna.users | |
Hello all,
I'm trying to use Ghostscript to split a pdf in jpeg images (1 per page). I have a C code which is working, and want to translate it in Java using JNA.
This is the Java code for my library :
public interface GhostscriptLibrary extends Library {
public GhostscriptLibrary INSTANCE = (GhostscriptLibrary)
Native.loadLibrary("gsdll32",
GhostscriptLibrary.class);
// int gsapi_new_instance (void **pinstance, void *caller_handle); public int gsapi_new_instance(PointerByReference instance, Pointer caller_handler);
// void gsapi_delete_instance (void *instance); public void gsapi_delete_instance(Pointer instance);
// int gsapi_init_with_args (void *instance, int argc, char **argv); public int gsapi_init_with_args(Pointer instance, int argc, String[] argv);
// int gsapi_exit (void *instance); public int gsapi_exit(Pointer instance); }
Note that the underlying C api functions are commented out.
Then, this is the calling class :
public class PdfExtractor {
public void extractPdf(String pdfPath) { GhostscriptLibrary gs = GhostscriptLibrary.INSTANCE; PointerByReference instancePointer = new PointerByReference(); gs.gsapi_new_instance(instancePointer, null);
String[] argv = { "pdf2ps", "-dNOPAUSE", "-dBATCH", "-dSAFER", "-sDEVICE=jpeg", "-dJPEGQ=100", "-dCOLORSCREEN=true", "-dNOINTERPOLATE", "-dGraphicsAlphaBits=2", "C:\\tmp\\pdf\\test-gs-java-%d.jpg", "-r300x300", pdfPath }; gs.gsapi_init_with_args(instancePointer.getPointer(), argv.length, argv); gs.gsapi_exit(instancePointer.getPointer()); gs.gsapi_delete_instance(instancePointer.getPointer()); } }
While running, I have a crash in /gsapi_init_with_args/, because of an access violation. If I delete the calls to /gsapi_init_with_args/ and /gsapi_exit/, all is fine (but unuseful). Can anybody help ?
Thanks in advance.
ps : configuration Windows XP, gsdll32.dll from GPL Ghostscript v8.63. ps 2 : stack trace with Native.setProtected(true) : Exception in thread "main" java.lang.Error: Invalid memory access at com.sun.jna.Function.invokeInt(Native Method) at com.sun.jna.Function.invoke(Function.java:294) at com.sun.jna.Function.invoke(Function.java:223) at com.sun.jna.Library$Handler.invoke(Library.java:204) at $Proxy1.gsapi_init_with_args(Unknown Source) at ********.PdfExtractor.extractPdf(PdfExtractor.java:16) at ********.Main.main(Main.java:18)
ps 3 : VM crash log file (Native.setProtected(false)) : # An unexpected error has been detected by Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0b0e665d, pid=844, tid=3516 # # Java VM: Java HotSpot(TM) Client VM (10.0-b22 mixed mode windows-x86) # Problematic frame: # C [gsdll32.dll+0x5665d] # # If you would like to submit a bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. #
--------------- T H R E A D ---------------
Current thread (0x00376400): JavaThread "main" [_thread_in_native, id=3516, stack(0x003a0000,0x003f0000)]
siginfo: ExceptionCode=0xc0000005, reading address 0x00000000
Registers: EAX=0x00000000, EBX=0x00000064, ECX=0x0000000c, EDX=0x00000000 ESP=0x003ee9f8, EBP=0x0ac956f0, ESI=0x0b26b6a4, EDI=0x00000000 EIP=0x0b0e665d, EFLAGS=0x00010293
Top of Stack: (sp=0x003ee9f8) 0x003ee9f8: 00376400 003ef8f0 003ef808 0b0e8f10 0x003eea08: 00000003 00000000 00000000 00000000 0x003eea18: 0ac9571c 0b30ffe8 0b310008 0b310028 0x003eea28: 00000000 00000000 6d94f6ee 02a504f8 0x003eea38: 003eea78 00376400 6d952009 00376400 0x003eea48: 00376068 00376b10 00000000 00000000 0x003eea58: 00000000 00000000 00000000 00000000 0x003eea68: 00000000 003eec98 0aede7f8 003eea90
Instructions: (pc=0x0b0e665d) 0x0b0e664d: 83 c7 04 89 7c 24 20 8b 3f be a4 b6 26 0b 8b c7 0x0b0e665d: 8a 18 8a cb 3a 1e 75 1c 84 c9 74 14 8a 58 01 8a
Stack: [0x003a0000,0x003f0000], sp=0x003ee9f8, free space=314k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) C [gsdll32.dll+0x5665d]







