Hi
I'm using JNI to access the exiv2 library (written in C++) in Java and I'm getting a weird runtime error in the JNI code. I've tried using various -Xms and -Xmx options, but that seems to have no affect. I've also tried running this code on JDK1.7.0 with the same result.
# 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:
RAX=0x0000000000000002
0x0000000000000002 is pointing to unknown location
RBX=0x000000000190db90
0x000000000190db90 is pointing to unknown location
RCX=0x0000000000000000
0x0000000000000000 is pointing to unknown location
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
R9 =0x000000000190db88
0x000000000190db88 is pointing to unknown location
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
R15=0x0000000000000003
0x0000000000000003 is pointing to unknown location
Top of Stack: (sp=0x00007ff319546270)
...
Instructions: (pc=0x00007ff31807757f)
0x00007ff31807756f: e2 03 48 03 57 58 31 c9 48 8b 32 48 85 f6 74 03
0x00007ff31807757f: 48 8b 0e 48 89 0a 8b 77 68 83 c0 01 39 f0 7c d1
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
7ff319387000-7ff319391000 rw-p 00000000 00:00 0
7ff319391000-7ff319447000 rw-p 00000000 00:00 0
7ff319447000-7ff31944a000 ---p 00000000 00:00 0
7ff31944a000-7ff31954d000 rw-p 00000000 00:00 0
7ff319562000-7ff31956a000 rw-s 00000000 08:03 1966453 /tmp/hsperfdata_hjed/4041
7ff31956a000-7ff31956b000 rw-p 00000000 00:00 0
7ff31956b000-7ff31956c000 r--p 00000000 00:00 0
7ff31956c000-7ff31956e000 rw-p 00000000 00:00 0
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:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
USERNAME=hjed
LD_LIBRARY_PATH=/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64
SHELL=/bin/bash
DISPLAY=:0.0
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
The java code is:
...
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());
}
}
and
/** 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++ code:
#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);
}
I've searched for a fix for this, but I can't find one. I don't have much experience using C++ so if I've made an obvious mistake in the C code I apologies.
Thanks for any help,
HJED
P.S. This is my first post on this site and I wasn't sure how much of the code I needed to show. Sorry if I've put to much up.