JNI'有问题的框架'导致JVM崩溃

时间:2011-01-01 04:49:44

标签: java c++ java-native-interface exiv2

我正在使用JNI访问Java中的exiv2库(用C ++编写),我在JNI代码中遇到了一个奇怪的运行时错误。我尝试过使用各种-Xms和-Xmx选项,但这似乎没有任何影响。我也尝试在JDK1.7.0上运行此代码,结果相同。

 # A fatal error has been detected by the Java Runtime Environment:
 #
 #  SIGSEGV (0xb) at pc=0x00007ff31807757f, pid=4041, tid=140682078746368
 #
 # JRE version: 6.0_20-b20
 # Java VM: OpenJDK 64-Bit Server VM (19.0-b09 mixed mode linux-amd64 )
 # Derivative: IcedTea6 1.9.2
 # Distribution: Ubuntu 10.10, package 6b20-1.9.2-0ubuntu2
 # Problematic frame:
 # V  [libjvm.so+0x42757f]
 #
 # If you would like to submit a bug report, please include
 # instructions how to reproduce the bug and visit:
 #   https://bugs.launchpad.net/ubuntu/+source/openjdk-6/
 #
 ---------------  T H R E A D  ---------------

 Current thread (0x000000000190d000):  JavaThread "main" [_thread_in_Java, id=4043, stack(0x00007ff319447000,0x00007ff319548000)]

 siginfo:si_signo=SIGSEGV: si_errno=0, si_code=1 (SEGV_MAPERR), si_addr=0x0000000000000024

 Registers:
 ...

 Register to memory mapping:

 ...

 RDX=0x00007ff3195463f8
 0x00007ff3195463f8 is pointing into the stack for thread: 0x000000000190d000
 "main" prio=10 tid=0x000000000190d000 nid=0xfcb runnable [0x0000000000000000]
    java.lang.Thread.State: RUNNABLE

 RSP=0x00007ff319546270
 0x00007ff319546270 is pointing into the stack for thread: 0x000000000190d000
 "main" prio=10 tid=0x000000000190d000 nid=0xfcb runnable [0x0000000000000000]
    java.lang.Thread.State: RUNNABLE

 RBP=0x00007ff319546270
 0x00007ff319546270 is pointing into the stack for thread: 0x000000000190d000
 "main" prio=10 tid=0x000000000190d000 nid=0xfcb runnable [0x0000000000000000]
    java.lang.Thread.State: RUNNABLE

 RSI=0x0000000000000024
 0x0000000000000024 is pointing to unknown location

 RDI=0x00007ff3195463e0
 0x00007ff3195463e0 is pointing into the stack for thread: 0x000000000190d000
 "main" prio=10 tid=0x000000000190d000 nid=0xfcb runnable [0x0000000000000000]
    java.lang.Thread.State: RUNNABLE

 R8 =0x000000000190d000
 "main" prio=10 tid=0x000000000190d000 nid=0xfcb runnable [0x0000000000000000]
    java.lang.Thread.State: RUNNABLE

 ...

 R10=0x00007ff319546300
 0x00007ff319546300 is pointing into the stack for thread: 0x000000000190d000
 "main" prio=10 tid=0x000000000190d000 nid=0xfcb runnable [0x0000000000000000]
    java.lang.Thread.State: RUNNABLE

 R11=0x0000000000000002
 0x0000000000000002 is pointing to unknown location

 R12=0x000000000190d000
 "main" prio=10 tid=0x000000000190d000 nid=0xfcb runnable [0x0000000000000000]
    java.lang.Thread.State: RUNNABLE

 R13=0x00007ff319546560
 0x00007ff319546560 is pointing into the stack for thread: 0x000000000190d000
 "main" prio=10 tid=0x000000000190d000 nid=0xfcb runnable [0x0000000000000000]
    java.lang.Thread.State: RUNNABLE

 R14=0x00007ff3195463e0
 0x00007ff3195463e0 is pointing into the stack for thread: 0x000000000190d000
 "main" prio=10 tid=0x000000000190d000 nid=0xfcb runnable [0x0000000000000000]
    java.lang.Thread.State: RUNNABLE

 ...


 Top of Stack: (sp=0x00007ff319546270)
 ...

 Instructions: (pc=0x00007ff31807757f)
 ...

 Stack: [0x00007ff319447000,0x00007ff319548000],  sp=0x00007ff319546270,  free space=1020k
 Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
 V  [libjvm.so+0x42757f]
 V  [libjvm.so+0x42866b]
 V  [libjvm.so+0x4275c8]
 V  [libjvm.so+0x4331bd]
 V  [libjvm.so+0x44e5c7]
 C  [libExiff2-binding.so+0x1f16]  _ZN7JNIEnv_15CallVoidMethodAEP8_jobjectP10_jmethodIDPK6jvalue+0x40
 C  [libExiff2-binding.so+0x1b96]  _Z8loadIPTCSt8auto_ptrIN5Exiv25ImageEEPKcP7JNIEnv_P8_jobject+0x2ba
 C  [libExiff2-binding.so+0x1d3f]  _Z7getVarsPKcP7JNIEnv_P8_jobject+0x176
 C  [libExiff2-binding.so+0x1de7]  Java_photo_exiv2_Exiv2MetaDataStore_impl_1loadFromExiv+0x4b
 j  photo.exiv2.Exiv2MetaDataStore.impl_loadFromExiv(Ljava/lang/String;Lphoto/exiv2/Exiv2MetaDataStore;)V+0
 j  photo.exiv2.Exiv2MetaDataStore.loadFromExiv2()V+9
 j  photo.exiv2.Exiv2MetaDataStore.loadData()V+1
 j  photo.exiv2.Exiv2MetaDataStore.<init>(Lphoto/ImageFile;)V+10
 j  test.Main.main([Ljava/lang/String;)V+76
 v  ~StubRoutines::call_stub
 V  [libjvm.so+0x428698]
 V  [libjvm.so+0x4275c8]
 V  [libjvm.so+0x432943]
 V  [libjvm.so+0x447f91]
 C  [java+0x3495]  JavaMain+0xd75


 ---------------  P R O C E S S  ---------------

 Java Threads: ( => current thread )
   0x00007ff2c4027800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=4060, stack(0x00007ff2c9052000,0x00007ff2c9153000)]
   0x00007ff2c4025000 JavaThread "CompilerThread1" daemon [_thread_blocked, id=4059, stack(0x00007ff2c9153000,0x00007ff2c9254000)]
   0x00007ff2c4022000 JavaThread "CompilerThread0" daemon [_thread_blocked, id=4058, stack(0x00007ff2c9254000,0x00007ff2c9355000)]
   0x00007ff2c401f800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=4057, stack(0x00007ff2c9355000,0x00007ff2c9456000)]
   0x00007ff2c4001000 JavaThread "Finalizer" daemon [_thread_blocked, id=4056, stack(0x00007ff2c994d000,0x00007ff2c9a4e000)]
   0x0000000001984000 JavaThread "Reference Handler" daemon [_thread_blocked, id=4055, stack(0x00007ff2c9a4e000,0x00007ff2c9b4f000)]
 =>0x000000000190d000 JavaThread "main" [_thread_in_Java, id=4043, stack(0x00007ff319447000,0x00007ff319548000)]

 Other Threads:
   0x000000000197d800 VMThread [stack: 0x00007ff2c9b4f000,0x00007ff2c9c50000] [id=4054]
   0x00007ff2c4032000 WatcherThread [stack: 0x00007ff2c8f51000,0x00007ff2c9052000] [id=4061]

 VM state:not at safepoint (normal execution)

 VM Mutex/Monitor currently owned by a thread: None

 Heap
  PSYoungGen      total 18432K, used 316K [0x00007ff2fed30000, 0x00007ff3001c0000, 0x00007ff313730000)
   eden space 15808K, 2% used [0x00007ff2fed30000,0x00007ff2fed7f0b8,0x00007ff2ffca0000)
   from space 2624K, 0% used [0x00007ff2fff30000,0x00007ff2fff30000,0x00007ff3001c0000)
   to   space 2624K, 0% used [0x00007ff2ffca0000,0x00007ff2ffca0000,0x00007ff2fff30000)
  PSOldGen        total 42240K, used 0K [0x00007ff2d5930000, 0x00007ff2d8270000, 0x00007ff2fed30000)
   object space 42240K, 0% used [0x00007ff2d5930000,0x00007ff2d5930000,0x00007ff2d8270000)
  PSPermGen       total 21248K, used 2827K [0x00007ff2cb330000, 0x00007ff2cc7f0000, 0x00007ff2d5930000)
   object space 21248K, 13% used [0x00007ff2cb330000,0x00007ff2cb5f2f60,0x00007ff2cc7f0000)

 Dynamic libraries:
 00400000-00409000 r-xp 00000000 08:03 141899                             /usr/lib/jvm/java-6-openjdk/jre/bin/java
 00608000-00609000 r--p 00008000 08:03 141899                             /usr/lib/jvm/java-6-openjdk/jre/bin/java
 00609000-0060a000 rw-p 00009000 08:03 141899                             /usr/lib/jvm/java-6-openjdk/jre/bin/java
 01904000-019ad000 rw-p 00000000 00:00 0                                  [heap]
 ...
 7ff2c820c000-7ff2c8232000 r-xp 00000000 08:03 917704                     /lib/libexpat.so.1.5.2
 7ff2c8232000-7ff2c8432000 ---p 00026000 08:03 917704                     /lib/libexpat.so.1.5.2
 7ff2c8432000-7ff2c8434000 r--p 00026000 08:03 917704                     /lib/libexpat.so.1.5.2
 7ff2c8434000-7ff2c8435000 rw-p 00028000 08:03 917704                     /lib/libexpat.so.1.5.2
 7ff2c8435000-7ff2c844a000 r-xp 00000000 08:03 917708                     /lib/libgcc_s.so.1
 7ff2c844a000-7ff2c8649000 ---p 00015000 08:03 917708                     /lib/libgcc_s.so.1
 7ff2c8649000-7ff2c864a000 r--p 00014000 08:03 917708                     /lib/libgcc_s.so.1
 7ff2c864a000-7ff2c864b000 rw-p 00015000 08:03 917708                     /lib/libgcc_s.so.1
 7ff2c864b000-7ff2c8733000 r-xp 00000000 08:03 134995                     /usr/lib/libstdc++.so.6.0.14
 7ff2c8733000-7ff2c8932000 ---p 000e8000 08:03 134995                     /usr/lib/libstdc++.so.6.0.14
 7ff2c8932000-7ff2c893a000 r--p 000e7000 08:03 134995                     /usr/lib/libstdc++.so.6.0.14
 7ff2c893a000-7ff2c893c000 rw-p 000ef000 08:03 134995                     /usr/lib/libstdc++.so.6.0.14
 7ff2c893c000-7ff2c8951000 rw-p 00000000 00:00 0 
 7ff2c8951000-7ff2c8af3000 r-xp 00000000 08:03 134599                     /usr/lib/libexiv2.so.6.0.0
 7ff2c8af3000-7ff2c8cf2000 ---p 001a2000 08:03 134599                     /usr/lib/libexiv2.so.6.0.0
 7ff2c8cf2000-7ff2c8d0f000 r--p 001a1000 08:03 134599                     /usr/lib/libexiv2.so.6.0.0
 7ff2c8d0f000-7ff2c8d10000 rw-p 001be000 08:03 134599                     /usr/lib/libexiv2.so.6.0.0
 7ff2c8d10000-7ff2c8d23000 rw-p 00000000 00:00 0 
 7ff2c8d42000-7ff2c8d45000 r-xp 00000000 08:03 800718                     /home/hjed/libExiff2-binding.so
 7ff2c8d45000-7ff2c8f44000 ---p 00003000 08:03 800718                     /home/hjed/libExiff2-binding.so
 7ff2c8f44000-7ff2c8f45000 r--p 00002000 08:03 800718                     /home/hjed/libExiff2-binding.so
 7ff2c8f45000-7ff2c8f46000 rw-p 00003000 08:03 800718                     /home/hjed/libExiff2-binding.so
 7ff2c8f46000-7ff2c8f49000 r--s 0000f000 08:03 141333                     /usr/lib/jvm/java-6-openjdk/jre/lib/ext/pulse-java.jar
 7ff2c8f49000-7ff2c8f51000 r--s 00066000 08:03 408472                     /usr/share/java/gnome-java-bridge.jar
 ...
 7ff2ca559000-7ff2ca55b000 r--s 0001d000 08:03 141354                     /usr/lib/jvm/java-6-openjdk/jre/lib/plugin.jar
 7ff2ca55b000-7ff2ca560000 r--s 00044000 08:03 141353                     /usr/lib/jvm/java-6-openjdk/jre/lib/netx.jar
 7ff2ca560000-7ff2ca592000 rw-p 00000000 00:00 0 
 7ff2ca592000-7ff2ca720000 r--s 038af000 08:03 141833                     /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar
 ...
 7ff31673b000-7ff316742000 r-xp 00000000 08:03 141867                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libzip.so
 7ff316742000-7ff316941000 ---p 00007000 08:03 141867                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libzip.so
 7ff316941000-7ff316942000 r--p 00006000 08:03 141867                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libzip.so
 7ff316942000-7ff316943000 rw-p 00007000 08:03 141867                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libzip.so
 7ff316943000-7ff31694f000 r-xp 00000000 08:03 921396                     /lib/libnss_files-2.12.1.so
 7ff31694f000-7ff316b4e000 ---p 0000c000 08:03 921396                     /lib/libnss_files-2.12.1.so
 7ff316b4e000-7ff316b4f000 r--p 0000b000 08:03 921396                     /lib/libnss_files-2.12.1.so
 7ff316b4f000-7ff316b50000 rw-p 0000c000 08:03 921396                     /lib/libnss_files-2.12.1.so
 7ff316b50000-7ff316b5a000 r-xp 00000000 08:03 921398                     /lib/libnss_nis-2.12.1.so
 7ff316b5a000-7ff316d59000 ---p 0000a000 08:03 921398                     /lib/libnss_nis-2.12.1.so
 7ff316d59000-7ff316d5a000 r--p 00009000 08:03 921398                     /lib/libnss_nis-2.12.1.so
 7ff316d5a000-7ff316d5b000 rw-p 0000a000 08:03 921398                     /lib/libnss_nis-2.12.1.so
 7ff316d5b000-7ff316d63000 r-xp 00000000 08:03 921393                     /lib/libnss_compat-2.12.1.so
 7ff316d63000-7ff316f62000 ---p 00008000 08:03 921393                     /lib/libnss_compat-2.12.1.so
 7ff316f62000-7ff316f63000 r--p 00007000 08:03 921393                     /lib/libnss_compat-2.12.1.so
 7ff316f63000-7ff316f64000 rw-p 00008000 08:03 921393                     /lib/libnss_compat-2.12.1.so
 7ff316f64000-7ff316f6c000 r-xp 00000000 08:03 141869                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/native_threads/libhpi.so
 7ff316f6c000-7ff31716b000 ---p 00008000 08:03 141869                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/native_threads/libhpi.so
 7ff31716b000-7ff31716c000 r--p 00007000 08:03 141869                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/native_threads/libhpi.so
 7ff31716c000-7ff31716d000 rw-p 00008000 08:03 141869                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/native_threads/libhpi.so
 7ff31716d000-7ff317184000 r-xp 00000000 08:03 921392                     /lib/libnsl-2.12.1.so
 7ff317184000-7ff317383000 ---p 00017000 08:03 921392                     /lib/libnsl-2.12.1.so
 7ff317383000-7ff317384000 r--p 00016000 08:03 921392                     /lib/libnsl-2.12.1.so
 7ff317384000-7ff317385000 rw-p 00017000 08:03 921392                     /lib/libnsl-2.12.1.so
 7ff317385000-7ff317387000 rw-p 00000000 00:00 0 
 7ff317387000-7ff3173b2000 r-xp 00000000 08:03 141850                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libjava.so
 7ff3173b2000-7ff3175b1000 ---p 0002b000 08:03 141850                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libjava.so
 7ff3175b1000-7ff3175b2000 r--p 0002a000 08:03 141850                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libjava.so
 7ff3175b2000-7ff3175b5000 rw-p 0002b000 08:03 141850                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libjava.so
 7ff3175b5000-7ff3175c3000 r-xp 00000000 08:03 141866                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libverify.so
 7ff3175c3000-7ff3177c2000 ---p 0000e000 08:03 141866                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libverify.so
 7ff3177c2000-7ff3177c4000 r--p 0000d000 08:03 141866                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libverify.so
 7ff3177c4000-7ff3177c5000 rw-p 0000f000 08:03 141866                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libverify.so
 7ff3177c5000-7ff3177cc000 r-xp 00000000 08:03 921405                     /lib/librt-2.12.1.so
 7ff3177cc000-7ff3179cb000 ---p 00007000 08:03 921405                     /lib/librt-2.12.1.so
 7ff3179cb000-7ff3179cc000 r--p 00006000 08:03 921405                     /lib/librt-2.12.1.so
 7ff3179cc000-7ff3179cd000 rw-p 00007000 08:03 921405                     /lib/librt-2.12.1.so
 7ff3179cd000-7ff317a4f000 r-xp 00000000 08:03 921390                     /lib/libm-2.12.1.so
 7ff317a4f000-7ff317c4e000 ---p 00082000 08:03 921390                     /lib/libm-2.12.1.so
 7ff317c4e000-7ff317c4f000 r--p 00081000 08:03 921390                     /lib/libm-2.12.1.so
 7ff317c4f000-7ff317c50000 rw-p 00082000 08:03 921390                     /lib/libm-2.12.1.so
 7ff317c50000-7ff3184c4000 r-xp 00000000 08:03 141871                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/libjvm.so
 7ff3184c4000-7ff3186c3000 ---p 00874000 08:03 141871                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/libjvm.so
 7ff3186c3000-7ff318739000 r--p 00873000 08:03 141871                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/libjvm.so
 7ff318739000-7ff318754000 rw-p 008e9000 08:03 141871                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/libjvm.so
 7ff318754000-7ff31878d000 rw-p 00000000 00:00 0 
 7ff31878d000-7ff318907000 r-xp 00000000 08:03 921385                     /lib/libc-2.12.1.so
 7ff318907000-7ff318b06000 ---p 0017a000 08:03 921385                     /lib/libc-2.12.1.so
 7ff318b06000-7ff318b0a000 r--p 00179000 08:03 921385                     /lib/libc-2.12.1.so
 7ff318b0a000-7ff318b0b000 rw-p 0017d000 08:03 921385                     /lib/libc-2.12.1.so
 7ff318b0b000-7ff318b10000 rw-p 00000000 00:00 0 
 7ff318b10000-7ff318b12000 r-xp 00000000 08:03 921388                     /lib/libdl-2.12.1.so
 7ff318b12000-7ff318d12000 ---p 00002000 08:03 921388                     /lib/libdl-2.12.1.so
 7ff318d12000-7ff318d13000 r--p 00002000 08:03 921388                     /lib/libdl-2.12.1.so
 7ff318d13000-7ff318d14000 rw-p 00003000 08:03 921388                     /lib/libdl-2.12.1.so
 7ff318d14000-7ff318d18000 r-xp 00000000 08:03 141838                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/jli/libjli.so
 7ff318d18000-7ff318f17000 ---p 00004000 08:03 141838                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/jli/libjli.so
 7ff318f17000-7ff318f18000 r--p 00003000 08:03 141838                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/jli/libjli.so
 7ff318f18000-7ff318f19000 rw-p 00004000 08:03 141838                     /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/jli/libjli.so
 7ff318f19000-7ff318f31000 r-xp 00000000 08:03 921401                     /lib/libpthread-2.12.1.so
 7ff318f31000-7ff319130000 ---p 00018000 08:03 921401                     /lib/libpthread-2.12.1.so
 7ff319130000-7ff319131000 r--p 00017000 08:03 921401                     /lib/libpthread-2.12.1.so
 7ff319131000-7ff319132000 rw-p 00018000 08:03 921401                     /lib/libpthread-2.12.1.so
 7ff319132000-7ff319136000 rw-p 00000000 00:00 0 
 7ff319136000-7ff31914c000 r-xp 00000000 08:03 917772                     /lib/libz.so.1.2.3.4
 7ff31914c000-7ff31934c000 ---p 00016000 08:03 917772                     /lib/libz.so.1.2.3.4
 7ff31934c000-7ff31934d000 r--p 00016000 08:03 917772                     /lib/libz.so.1.2.3.4
 7ff31934d000-7ff31934e000 rw-p 00017000 08:03 917772                     /lib/libz.so.1.2.3.4
 7ff31934e000-7ff31936e000 r-xp 00000000 08:03 921379                     /lib/ld-2.12.1.so
 ...
 7ff319562000-7ff31956a000 rw-s 00000000 08:03 1966453                    /tmp/hsperfdata_hjed/4041
 ...
 7ff31956e000-7ff31956f000 r--p 00020000 08:03 921379                     /lib/ld-2.12.1.so
 7ff31956f000-7ff319570000 rw-p 00021000 08:03 921379                     /lib/ld-2.12.1.so
 7ff319570000-7ff319571000 rw-p 00000000 00:00 0 
 7fff0fb03000-7fff0fb24000 rw-p 00000000 00:00 0                          [stack]
 7fff0fbff000-7fff0fc00000 r-xp 00000000 00:00 0                          [vdso]
 ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

 VM Arguments:
 jvm_args: -Dfile.encoding=UTF-8 
 java_command: test.Main
 Launcher Type: SUN_STANDARD

 Environment Variables:
 ...

 Signal Handlers:
 SIGSEGV: [libjvm.so+0x712700], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
 SIGBUS: [libjvm.so+0x712700], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
 SIGFPE: [libjvm.so+0x5d4020], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
 SIGPIPE: [libjvm.so+0x5d4020], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
 SIGXFSZ: [libjvm.so+0x5d4020], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
 SIGILL: [libjvm.so+0x5d4020], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
 SIGUSR1: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000
 SIGUSR2: [libjvm.so+0x5d3730], sa_mask[0]=0x00000004, sa_flags=0x10000004
 SIGHUP: [libjvm.so+0x5d61a0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
 SIGINT: SIG_IGN, sa_mask[0]=0x00000000, sa_flags=0x00000000
 SIGTERM: [libjvm.so+0x5d61a0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004
 SIGQUIT: [libjvm.so+0x5d61a0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004


 ---------------  S Y S T E M  ---------------

 OS:Ubuntu 10.10 (maverick)
 uname:Linux 2.6.35-24-generic #42-Ubuntu SMP Thu Dec 2 02:41:37 UTC 2010 x86_64
 libc:glibc 2.12.1 NPTL 2.12.1 
 rlimit: STACK 8192k, CORE 0k, NPROC infinity, NOFILE 1024, AS infinity
 load average:0.25 0.16 0.21

 /proc/meminfo:
 MemTotal:        4048200 kB
 MemFree:         1230476 kB
 Buffers:          589572 kB
 Cached:           911132 kB
 SwapCached:            0 kB
 Active:          1321712 kB
 Inactive:        1202272 kB
 Active(anon):    1023852 kB
 Inactive(anon):     7168 kB
 Active(file):     297860 kB
 Inactive(file):  1195104 kB
 Unevictable:          64 kB
 Mlocked:              64 kB
 SwapTotal:       7065596 kB
 SwapFree:        7065596 kB
 Dirty:               632 kB
 Writeback:             0 kB
 AnonPages:       1023368 kB
 Mapped:           145832 kB
 Shmem:              7728 kB
 Slab:             111136 kB
 SReclaimable:      66316 kB
 SUnreclaim:        44820 kB
 KernelStack:        3824 kB
 PageTables:        27736 kB
 NFS_Unstable:          0 kB
 Bounce:                0 kB
 WritebackTmp:          0 kB
 CommitLimit:     9089696 kB
 Committed_AS:    2378396 kB
 VmallocTotal:   34359738367 kB
 VmallocUsed:      332928 kB
 VmallocChunk:   34359397884 kB
 HardwareCorrupted:     0 kB
 HugePages_Total:       0
 HugePages_Free:        0
 HugePages_Rsvd:        0
 HugePages_Surp:        0
 Hugepagesize:       2048 kB
 DirectMap4k:       67136 kB
 DirectMap2M:     4118528 kB

 CPU:total 8 (4 cores per cpu, 2 threads per core) family 6 model 26 stepping 5, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, ht

 Memory: 4k page, physical 4048200k(1230476k free), swap 7065596k(7065596k free)

 vm_info: OpenJDK 64-Bit Server VM (19.0-b09) for linux-amd64 JRE (1.6.0_20-b20), built on Dec 10 2010 19:45:55 by "buildd" with gcc 4.4.5

 time: Sat Jan  1 14:12:27 2011
 elapsed time: 0 seconds


java代码是:

...
public class Main {

    public static void main(String[] args) {
        ...
        ImageFile img = new ImageFile(System.getProperty("user.home") + "/PC100001.JPG");
        Exiv2MetaDataStore e = new Exiv2MetaDataStore(img);
        Iterator<Entry<String, String>> i = e.entrySet().iterator();
        while (i.hasNext()) {
            Entry<String, String> entry = i.next();
            System.out.println(entry.getKey() + ":" + entry.getValue());
        }
        //if you switch this print statment with the while loop you get the same error. 
        //System.out.print(e.toString()); 
    }
}

/**NB: MetaDataStore is an abstract class that extends HashMap<String,String> */
public class Exiv2MetaDataStore  extends MetaDataStore{
     ...
     private final ImageFile F;
     /**
      * Creates an meta data store from an ImageFile using Exiv2
      * this calls loadData();
      * @param f
      */
     public Exiv2MetaDataStore(ImageFile f) {
         F = f;
         loadData();
     }
     ...
     @Override
     protected void loadData() {
         loadFromExiv2();
     }
     ...     
     private void loadFromExiv2() {
         impl_loadFromExiv(F.getAbsolutePath(), this);
     }
     private native void impl_loadFromExiv(String path, Exiv2MetaDataStore str);
     //this method called by the C++ code
     public void exiv2_reciveElement(String key, String value) {
         super.put(key,value);
     }
     static {           
         Runtime.getRuntime().load("/home/hjed/libExiff2-binding.so");
     }

 }

C ++代码:

 #include <exif.hpp>
 #include <image.hpp>
 #include <iptc.hpp>
 #include <exiv2/exiv2.hpp>
 #include <exiv2/error.hpp>
 #include <iostream>
 #include <iomanip>
 #include <cassert>

 void loadIPTC(Exiv2::Image::AutoPtr  image, const char * path, JNIEnv * env, jobject obj) {
     Exiv2::IptcData &iptcData = image->iptcData();

     //load method 
     jclass cls = env->GetObjectClass(obj);
     jmethodID mid = env->GetMethodID(cls, "exiv2_reciveElement", "(Ljava/lang/String;Ljava/lang/String;)V");

     //is there any IPTC data AND check that method exists
     if (iptcData.empty() || (mid == NULL)) {
         std::string error(path);
         error += ": failed loading IPTC data, there may not be any data";
     } else {
         Exiv2::IptcData::iterator end = iptcData.end();
         for (Exiv2::IptcData::iterator md = iptcData.begin(); md != end; ++md) {
             jvalue values[2];
             const char* key =  md->key().c_str();
             values[0].l = env->NewStringUTF(key);
             md->value().toString().c_str();
             const char* value = md->typeName();
             values[2].l = env->NewStringUTF(value);
             //If I replace the code for values[2] with the commented out code I get the same error.
             //const char* type = md->typeName();
             //values[2].l = env->NewStringUTF(type);
             env->CallVoidMethodA(obj, mid, values);
         }
     }
 }

 void getVars(const char* path, JNIEnv * env, jobject obj) {
     //Load image
     Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(path);
     assert(image.get() != 0);
     image->readMetadata();
     //Load IPTC data
     loadIPTC(image, path, env, obj);

 }

 JNIEXPORT void JNICALL Java_photo_exiv2_Exiv2MetaDataStore_impl_1loadFromExiv(JNIEnv * env, jobject obj, jstring path, jobject obj2) {
     const char* path2 = env->GetStringUTFChars(path, NULL);
     getVars(path2, env, obj);
     env->ReleaseStringUTFChars(path, path2);
 }

我已经为此寻找了解决办法,但我找不到一个。我没有太多使用C ++的经验,所以如果我在C代码中犯了一个明显的错误,我很抱歉。

感谢您的帮助,
HJED

P.S。这是我在这个网站上的第一篇文章,我不确定需要显示多少代码。对不起,如果我放了很多。

--------编辑:按照建议添加gdm回溯-----------
SIGSEGV的gdm回溯:

 #0  0x00007ffff6b0557f in JavaCallArguments::parameters() () from /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/libjvm.so
 #1  0x00007ffff6b0666b in JavaCalls::call_helper(JavaValue*, methodHandle*, JavaCallArguments*, Thread*) () from /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/libjvm.so
 #2  0x00007ffff6b055c8 in JavaCalls::call(JavaValue*, methodHandle, JavaCallArguments*, Thread*) () from /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/libjvm.so
 #3  0x00007ffff6b111bd in jni_invoke_nonstatic(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, Thread*) ()
    from /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/libjvm.so
 #4  0x00007ffff6b2c5c7 in jni_CallVoidMethodA () from /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/libjvm.so
 #5  0x00007fffa77ccf16 in JNIEnv_::CallVoidMethodA (this=0x6131c8, obj=0x7ffff7fd3818, methodID=0x67e278, args=0x7ffff7fd3630) at /usr/lib/jvm/java-6-openjdk/include/jni.h:1063
 #6  0x00007fffa77ccb96 in loadIPTC (image=..., path=0x6ca640 "/home/hjed/PC100001.JPG", env=0x6131c8, obj=0x7ffff7fd3818) at src/main.cpp:36
 #7  0x00007fffa77ccd3f in getVars (path=0x6ca640 "/home/hjed/PC100001.JPG", env=0x6131c8, obj=0x7ffff7fd3818) at src/main.cpp:48
 #8  0x00007fffa77ccde7 in Java_photo_exiv2_Exiv2MetaDataStore_impl_1loadFromExiv (env=0x6131c8, obj=0x7ffff7fd3818, path=0x7ffff7fd3810, obj2=0x7ffff7fd3808) at src/main.cpp:54
 #9  0x00007ffff21d9cc8 in ?? ()
 #10 0x0000000000000000 in ?? ()

main.cpp:54是:

getVars(path2, env, obj);

main.cpp:48是

loadIPTC(image, path, env, obj);

main.cpp:36是

env->CallVoidMethodA(obj, mid, values);

-------编辑:使用-cacao。下午5:15(AEDT)1/1/11 ---------

我注意到上面看到的堆栈跟踪错误来自特定于'server'vm的库,所以我尝试了-cacao VM选项。 而不是jni崩溃我得到了NullPointerException:

 Exception in thread "main" java.lang.NullPointerException
    at test.Main.main(Main.java:29)

我在发生异常的地方添加了一些调试代码(参见下文)并发现那里存在NullPointerException是不可能的。

修改后的代码:

        while (i.hasNext()) {
             Entry<String, String> entry = i.next();
             if (entry == null) {
                 System.out.println("entry is null");
             } else if (entry.getKey() == null || entry.getValue() == null) {
                 System.out.println("Key and value are null");
             } else if (entry.getKey() == null) {
                 System.out.println("Key is null");
             } else if (entry.getValue() == null) {
                 System.out.println("Value is null");
             } else {
                 System.out.println(entry.getKey() + ":" + entry.getValue()); //This throws a NullPointerException.
             }
         }


我认为这可能是同样的错误,只是处理不同的方式?再次感谢您的帮助 编辑:将位ORing更改为||由Favonius提取

1 个答案:

答案 0 :(得分:1)

在gdb下运行Java,运行,看看sigsegv上的回溯是什么。

...

您设置值[0]和值[2],但不设置值[1]。