C callback with JNA makes JRE crash - java

I'm having problems handling callbacks in JNA.
I'm trying to use a C API that uses callbacks to handle several session events (logged in, logged out, connection problem...).
The session object (called sp_session) is an opaque struct. All the callbacks are registered in a sp_session_callbacks structure. According to the API, I am supposed to declare the callbacks object, and put it into a Config object that I will provide when creating the sp_session object. If I don't want to use certain callbacks, I am supposed to initialize them with null. The API is using the __stdcall calling convention.
Here is a snippet of the C header that's relevant to my problem:
#define SP_CALLCONV __stdcall
typedef struct sp_session sp_session; ///< Representation of a session
typedef enum sp_error {
SP_ERROR_OK = 0,
SP_ERROR_BAD_API_VERSION = 1,
/* More errors */
} sp_error;
typedef struct sp_session_callbacks {
/**
* Called when login has been processed and was successful
*/
void (SP_CALLCONV *logged_in)(sp_session *session, sp_error error);
/**
* Called when logout has been processed. Either called explicitly
* if you initialize a logout operation, or implicitly if there
* is a permanent connection error
*
* #param[in] session Session
*/
void (SP_CALLCONV *logged_out)(sp_session *session);
/**
* Called when there is a connection error, and the library has problems
* reconnecting to the Spotify service. Could be called multiple times (as
* long as the problem is present)
*/
void (SP_CALLCONV *connection_error)(sp_session *session, sp_error error);
/* More callbacks */
} sp_session_callbacks;
/**
* Initialize a session. The session returned will be initialized, but you will need
* to log in before you can perform any other operation
*/
SP_LIBEXPORT(sp_error) sp_session_create(const sp_session_config *config, sp_session **sess);
Here is my equivalent JNA code:
The sp_session object
public class sp_session extends PointerType{
public sp_session(Pointer address) {
super(address);
}
public sp_session() {
super();
}
}
The sp_session_callbacks object, containing all the callbacks
public class sp_session_callbacks extends Structure{
public LoggedIn logged_in;
public LoggedOut logged_out;
public ConnectionError connection_error;
}
The callbacks object (here is LoggedIn, but of course I have one for each callback)
public interface LoggedIn extends StdCallCallback {
public void logged_in(sp_session session, int error);
}
The native library, with the declaration of all the methods
public interface JLibspotify extends StdCallLibrary{
int sessionCreate(sp_session_config config, PointerByReference sess);
int sessionLogin(sp_session session, String username, String password);
// All the other methods defined by the API
}
And my main class, binding it all together
public class Test{
static{
System.loadLibrary("libspotify");
}
public static void main(String[] args){
JLibspotify lib = (JLibspotify)Native.loadLibrary("libspotify", JLibspotify.class);
sp_session_config cfg = new sp_session_config();
}
sp_session_callbacks sessCallbacks = new sp_session_callbacks();
LoggedIn loggedInCallback = new LoggedIn(){
public void logged_in(sp_session session, int error) {
System.out.println("logged_in() called");
}
};
sessCallbacks.logged_in = loggedInCallback;
cfg.session_callbacks = sessCallbacks;
PointerByReference sessionPbr = new PointerByReference();
int error_id = sessionCreate(cfg, sessionPbr); // CRASHES HERE
sp_session mySession = new sp_session(sessionPbr.getValue());
}
}
So, the sessionCreate function call makes the JRE crash with the trace at the end of the post EXCEPTION_ACCESS_VIOLATION (0xc0000005) problematic frame: C [jna3666290841889849729.dll+0xa3f4].
It looks like the logged_in callback is causing this, because when I set it to null it runs ok. Plus, if I initialize the connection_error callback, that has the exact same signature, it doesn't crash either.
I'm running version 3.2.7 of JNA. I tried with an anterior version (3.0.9) and it also failed.
I'm running the JDK 1.7 beta version, but I tried with the 1.6 and it also failed.
Thank you!
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0499a3f4, pid=1368, tid=1344
#
# JRE version: 7.0-b129
# Java VM: Java HotSpot(TM) Client VM (21.0-b01 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [jna3666290841889849729.dll+0xa3f4]
#
# 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 (0x01b79400): JavaThread "main" [_thread_in_native, id=1344, stack(0x00340000,0x00390000)]
siginfo: ExceptionCode=0xc0000005, reading address 0x1993053a
Registers:
EAX=0x19930522, EBX=0x100dc77c, ECX=0x00010004, EDX=0x1008d3e0
ESP=0x0038f58c, EBP=0x0038f5b4, ESI=0x0038f5a4, EDI=0x100b79b0
EIP=0x0499a3f4, EFLAGS=0x00210212
Top of Stack: (sp=0x0038f58c)
0x0038f58c: 100dc77c 0038f5a4 00010004 0038f688
0x0038f59c: 05983de0 05981330 0598289c 05983de0
0x0038f5ac: 05983de0 00000014 0038f688 1008d3ea
0x0038f5bc: 05983de0 10030d77 0038fc44 100b79b0
0x0038f5cc: ffffffff 1008d334 00000000 05983de0
0x0038f5dc: 1008d3e0 05983fc4 1008d9fd 0038f770
0x0038f5ec: 00000000 00000000 7275016a 055310b0
0x0038f5fc: 00000000 00010001 00000000 00000000
Instructions: (pc=0x0499a3f4)
0x0499a3d4: 01 00 89 e5 57 56 8d 75 f0 53 83 ec 1c 8b 7d 14
0x0499a3e4: 8b 5f 4c 8b 03 89 4c 24 08 89 74 24 04 89 1c 24
0x0499a3f4: ff 50 18 83 ec 0c 85 c0 0f 94 c0 0f b6 c0 85 c0
0x0499a404: 89 45 ec 75 19 8b 03 31 d2 89 54 24 08 89 74 24
Register to memory mapping:
EAX=0x19930522 is an unknown value
EBX=0x100dc77c is an unknown value
ECX=0x00010004 is an unknown value
EDX=0x1008d3e0 is an unknown value
ESP=0x0038f58c is pointing into the stack for thread: 0x01b79400
EBP=0x0038f5b4 is pointing into the stack for thread: 0x01b79400
ESI=0x0038f5a4 is pointing into the stack for thread: 0x01b79400
EDI=0x100b79b0 is an unknown value
Stack: [0x00340000,0x00390000], sp=0x0038f58c, free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [jna3666290841889849729.dll+0xa3f4] Java_com_sun_jna_Native_initialize_1ffi_1type+0x1054
C [libspotify.dll+0x8d3ea] sp_error_message+0x35a
C [jna3666290841889849729.dll+0xcb77] Java_com_sun_jna_Native_initialize_1ffi_1type+0x37d7
C [jna3666290841889849729.dll+0xc7c2] Java_com_sun_jna_Native_initialize_1ffi_1type+0x3422
C [jna3666290841889849729.dll+0x4561] Java_com_sun_jna_Pointer__1getString+0xa31
C [jna3666290841889849729.dll+0x4d2e] Java_com_sun_jna_Function_invokeInt+0x2e
j com.sun.jna.Function.invokeInt(I[Ljava/lang/Object;)I+0
j com.sun.jna.Function.invoke([Ljava/lang/Object;Ljava/lang/Class;Z)Ljava/lang/Object;+315
j com.sun.jna.Function.invoke(Ljava/lang/Class;[Ljava/lang/Object;Ljava/util/Map;)Ljava/lang/Object;+214
j com.sun.jna.Library$Handler.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+341
j $Proxy0.sp_session_create(Lcom/nbarraille/jspotify/model/sp_session_config;Lcom/sun/jna/ptr/PointerByReference;)I+20
j com.nbarraille.jspotify.main.Test.main([Ljava/lang/String;)V+273
v ~StubRoutines::call_stub
V [jvm.dll+0x115f6d]
V [jvm.dll+0x1b788e]
V [jvm.dll+0x115fed]
V [jvm.dll+0xa2507]
V [jvm.dll+0xac867]
C [javaw.exe+0x209e]
C [javaw.exe+0xa23b]
C [javaw.exe+0xa2c5]
C [kernel32.dll+0x51194] BaseThreadInitThunk+0x12
C [ntdll.dll+0x5b429] RtlInitializeExceptionChain+0x63
C [ntdll.dll+0x5b3fc] RtlInitializeExceptionChain+0x36
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.sun.jna.Function.invokeInt(I[Ljava/lang/Object;)I+0
j com.sun.jna.Function.invoke([Ljava/lang/Object;Ljava/lang/Class;Z)Ljava/lang/Object;+315
j com.sun.jna.Function.invoke(Ljava/lang/Class;[Ljava/lang/Object;Ljava/util/Map;)Ljava/lang/Object;+214
j com.sun.jna.Library$Handler.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+341
j $Proxy0.sp_session_create(Lcom/nbarraille/jspotify/model/sp_session_config;Lcom/sun/jna/ptr/PointerByReference;)I+20
j com.nbarraille.jspotify.main.Test.main([Ljava/lang/String;)V+273
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x0182fc00 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=4664, stack(0x04170000,0x041c0000)]
0x0182ac00 JavaThread "C1 CompilerThread0" daemon [_thread_blocked, id=1728, stack(0x01b20000,0x01b70000)]
0x01829800 JavaThread "Attach Listener" daemon [_thread_blocked, id=112, stack(0x04020000,0x04070000)]
0x01826400 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=5836, stack(0x03ea0000,0x03ef0000)]
0x01819800 JavaThread "Finalizer" daemon [_thread_blocked, id=4724, stack(0x03f80000,0x03fd0000)]
0x01817800 JavaThread "Reference Handler" daemon [_thread_blocked, id=3940, stack(0x01ad0000,0x01b20000)]
=>0x01b79400 JavaThread "main" [_thread_in_native, id=1344, stack(0x00340000,0x00390000)]
Other Threads:
0x01816400 VMThread [stack: 0x01a30000,0x01a80000] [id=3876]
0x01843000 WatcherThread [stack: 0x040d0000,0x04120000] [id=4636]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 4928K, used 3630K [0x23450000, 0x239a0000, 0x289a0000)
eden space 4416K, 82% used [0x23450000, 0x237db858, 0x238a0000)
from space 512K, 0% used [0x238a0000, 0x238a0000, 0x23920000)
to space 512K, 0% used [0x23920000, 0x23920000, 0x239a0000)
tenured generation total 10944K, used 0K [0x289a0000, 0x29450000, 0x33450000)
the space 10944K, 0% used [0x289a0000, 0x289a0000, 0x289a0200, 0x29450000)
compacting perm gen total 12288K, used 860K [0x33450000, 0x34050000, 0x37450000)
the space 12288K, 7% used [0x33450000, 0x33527190, 0x33527200, 0x34050000)
ro space 10240K, 43% used [0x37450000, 0x3789ce40, 0x3789d000, 0x37e50000)
rw space 12288K, 53% used [0x37e50000, 0x384c2710, 0x384c2800, 0x38a50000)
Code Cache [0x01e90000, 0x01f20000, 0x03e90000)
total_blobs=234 nmethods=82 adapters=88 free_code_cache=32972224 largest_free_block=0
Dynamic libraries:
0x00880000 - 0x008b0000 C:\Program Files\Java\jdk1.7.0\bin\javaw.exe
0x778f0000 - 0x77a2d000 C:\Windows\SYSTEM32\ntdll.dll
0x77070000 - 0x77144000 C:\Windows\system32\kernel32.dll
0x75cf0000 - 0x75d3a000 C:\Windows\system32\KERNELBASE.dll
0x60000000 - 0x60041000 C:\Program Files\BitDefender\BitDefender 2011\Active Virus Control\Midas_00078_002\midas32.dll
0x61000000 - 0x61028000 C:\Program Files\BitDefender\BitDefender 2011\Active Virus Control\Midas_00078_002\plugin_base.m32
0x67000000 - 0x67048000 C:\Program Files\BitDefender\BitDefender 2011\Active Virus Control\Midas_00078_002\plugin_nt.m32
0x64000000 - 0x64021000 C:\Program Files\BitDefender\BitDefender 2011\Active Virus Control\Midas_00078_002\plugin_registry.m32
0x62000000 - 0x6202d000 C:\Program Files\BitDefender\BitDefender 2011\Active Virus Control\Midas_00078_002\plugin_extra.m32
0x65000000 - 0x6501a000 C:\Program Files\BitDefender\BitDefender 2011\Active Virus Control\Midas_00078_002\plugin_net.m32
0x63000000 - 0x630a6000 C:\Program Files\BitDefender\BitDefender 2011\Active Virus Control\Midas_00078_002\plugin_fragments.m32
0x75e10000 - 0x75eb0000 C:\Windows\system32\ADVAPI32.dll
0x775c0000 - 0x7766c000 C:\Windows\system32\msvcrt.dll
0x75d50000 - 0x75d69000 C:\Windows\SYSTEM32\sechost.dll
0x77670000 - 0x77711000 C:\Windows\system32\RPCRT4.dll
0x76f00000 - 0x76fc9000 C:\Windows\system32\USER32.dll
0x77a50000 - 0x77a9e000 C:\Windows\system32\GDI32.dll
0x77a30000 - 0x77a3a000 C:\Windows\system32\LPK.dll
0x75d70000 - 0x75e0d000 C:\Windows\system32\USP10.dll
0x74830000 - 0x749ce000 C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16661_none_420fe3fa2b8113bd\COMCTL32.dll
0x772f0000 - 0x77347000 C:\Windows\system32\SHLWAPI.dll
0x775a0000 - 0x775bf000 C:\Windows\system32\IMM32.DLL
0x75eb0000 - 0x75f7c000 C:\Windows\system32\MSCTF.dll
0x72740000 - 0x727fe000 C:\Program Files\Java\jdk1.7.0\jre\bin\msvcr100.dll
0x01b80000 - 0x01e89000 C:\Program Files\Java\jdk1.7.0\jre\bin\client\jvm.dll
0x746c0000 - 0x746f2000 C:\Windows\system32\WINMM.dll
0x73920000 - 0x7392c000 C:\Program Files\Java\jdk1.7.0\jre\bin\verify.dll
0x73330000 - 0x73350000 C:\Program Files\Java\jdk1.7.0\jre\bin\java.dll
0x75d40000 - 0x75d45000 C:\Windows\system32\PSAPI.DLL
0x733a0000 - 0x733b3000 C:\Program Files\Java\jdk1.7.0\jre\bin\zip.dll
0x10000000 - 0x10259000 C:\Windows\System32\libspotify.dll
0x77150000 - 0x77185000 C:\Windows\system32\WS2_32.dll
0x77a40000 - 0x77a46000 C:\Windows\system32\NSI.dll
0x75ba0000 - 0x75cbc000 C:\Windows\system32\CRYPT32.dll
0x75ab0000 - 0x75abc000 C:\Windows\system32\MSASN1.dll
0x74ee0000 - 0x74f38000 C:\Windows\system32\WINHTTP.dll
0x74e90000 - 0x74edf000 C:\Windows\system32\webio.dll
0x754c0000 - 0x754d6000 C:\Windows\system32\CRYPTSP.dll
0x75260000 - 0x7529b000 C:\Windows\system32\rsaenh.dll
0x750a0000 - 0x750b7000 C:\Windows\system32\USERENV.dll
0x75a40000 - 0x75a4b000 C:\Windows\system32\profapi.dll
0x75a30000 - 0x75a3c000 C:\Windows\system32\CRYPTBASE.dll
0x728a0000 - 0x728b6000 C:\Program Files\Java\jdk1.7.0\jre\bin\net.dll
0x75480000 - 0x754bc000 C:\Windows\system32\mswsock.dll
0x75470000 - 0x75476000 C:\Windows\System32\wship6.dll
0x73950000 - 0x73960000 C:\Windows\system32\NLAapi.dll
0x75340000 - 0x75384000 C:\Windows\system32\DNSAPI.dll
0x71030000 - 0x71038000 C:\Windows\System32\winrnr.dll
0x71020000 - 0x71030000 C:\Windows\system32\napinsp.dll
0x71000000 - 0x71012000 C:\Windows\system32\pnrpnsp.dll
0x74fd0000 - 0x74fd5000 C:\Windows\System32\wshtcpip.dll
0x74d30000 - 0x74d4c000 C:\Windows\system32\IPHLPAPI.DLL
0x74d20000 - 0x74d27000 C:\Windows\system32\WINNSI.DLL
0x70c60000 - 0x70c66000 C:\Windows\system32\rasadhlp.dll
0x71ba0000 - 0x71bd8000 C:\Windows\System32\fwpuclnt.dll
0x73930000 - 0x7393f000 C:\Program Files\Java\jdk1.7.0\jre\bin\nio.dll
0x04990000 - 0x049e5000 C:\Users\nbarraille\AppData\Local\Temp\jna3666290841889849729.dll
VM Arguments:
jvm_args: -Djava.library.path=C:\Windows\System32 -Dfile.encoding=Cp1252
java_command: com.nbarraille.jspotify.main.Test
Launcher Type: SUN_STANDARD
Environment Variables:
PATH=C:/Program Files/Java/jdk1.7.0/bin/../jre/bin/client;C:/Program Files/Java/jdk1.7.0/bin/../jre/bin;C:/Program Files/Java/jdk1.7.0/bin/../jre/lib/i386;C:\Windows\System32
USERNAME=nbarraille
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 10, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows 7 Build 7600
CPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 23 stepping 10, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1
Memory: 4k page, physical 3624108k(885020k free), swap 7246452k(3637664k free)
vm_info: Java HotSpot(TM) Client VM (21.0-b01) for windows-x86 JRE (1.7.0-ea-b129), built on Feb 10 2011 07:43:39 by "java_re" with unknown MS VC++:1600
time: Mon Mar 07 14:25:08 2011
elapsed time: 0 seconds
EDIT:
*Code to test the API in C*
#include "api.h"
/* --- Data --- */
const uint8_t g_appkey[] = {/*My appkey*/};
/* --------------------------- SESSION CALLBACKS ------------------------- */
static void logged_in(sp_session *sess, sp_error error){
printf("logged_in() called: \n");
}
static void log_message(sp_session *sess, const char *data){
printf("log_message() called %s : \n", data);
}
static void notify_main_thread(sp_session *sess){
printf("notify_main_thread() called \n");
}
static sp_session_callbacks session_callbacks = {
//.logged_in = (void*)&logged_in,
//.notify_main_thread = (void*)&notify_main_thread,
//.log_message = (void*)&log_message,
};
static sp_session_config spconfig = {
.api_version = 7,
.cache_location = "tmp",
.settings_location = "tmp",
.application_key = g_appkey,
.application_key_size = sizeof(g_appkey),
.user_agent = "jspotify",
.callbacks = &session_callbacks,
.userdata = NULL
};
int main(int argc, char **argv)
{
sp_session *sp;
const char *username = "foo";
const char *password = "bar";
spconfig.application_key_size = sizeof(g_appkey);
printf("Creating session \n");
sp_error err = sp_session_create(&spconfig, &sp);
if(err != 0){
printf("Error occured: %d \n", err);
return 0;
}
printf("Login\n");
sp_session_login(sp, username, password);
Sleep(10000);
return 0;
}
When I run it like this (without callbacks), the output is:
Creating session
Login
And when I register the callbacks (uncomment the lines), it doesn't even print anything!
It looks like it doesn't print anything when a callback is called, because if I comment the sp_session_login line, only the declaration of notify_main_thread (which is the only one printed) will prevent the program from printing...

When you have a C structure like:
struct Foo {
Bar* bar
}
i.e. one which contains a pointer to another structure, your JNA implementation of Bar (class Bar extends Structure) must also implement the Structure.ByReference interface -- otherwise JNA will think that struct Foo contains an instance of struct Bar instead of a pointer to a struct Bar, and an illegal memory access will result as the C code interprets a value in the Bar instance as a pointer.
You need to add implements Structure.ByReference to the sp_session_callbacks class.
Thanks for inspiring me to look at JNA -- it's pretty cool!
Output of this code is:
sp_session_create returned 0
sp_session_login returned 0
log_message() called:14:16:53.825 I [ap:1388] Connecting to AP ap.spotify.com:4070
log_message() called:14:16:54.061 I [ap:938] Connected to AP: 193.182.8.11:4070
log_message() called:14:16:54.765 E [ap:3396] Connection error: 401
Process finished with exit code 0
import com.sun.jna.*;
import com.sun.jna.ptr.PointerByReference;
import java.sql.Connection;
public class JNATest {
// static {
// System.loadLibrary("libspotify");
// }
public interface JLibspotify extends Library {
int sp_session_create(sp_session_config config, PointerByReference sess);
int sp_session_login(sp_session session, String username, String password);
// All the other methods defined by the API
}
public static class sp_session extends PointerType {
public sp_session(Pointer address) {
super(address);
}
public sp_session() {
super();
}
}
public static class sp_session_config extends Structure {
public int api_version = 7; // The version of the Spotify API your application is compiled with.
public String cache_location = ".";
public String settings_location = ".";
public Pointer application_key; // Your application key.
public int application_key_size; // The size of the application key in bytes
public String user_agent = "jspotify";
public sp_session_callbacks callbacks; // Delivery callbacks for session events. NULL if not interested in any callbacks
public Pointer userdata; // User supplied data for your application
public boolean compress_playlists;
public boolean dont_save_metadata_for_playlists;
public boolean initially_unload_playlists;
}
public interface LoggedIn extends Callback {
public void logged_in(sp_session session, int error);
}
public interface LoggedOut extends Callback {
public void logged_out(sp_session session, int error);
}
public interface ConnectionError extends Callback {
public void connection_error(sp_session session, int error);
}
public static class sp_session_callbacks extends Structure implements Structure.ByReference{
public LoggedIn logged_in; // Called when login has been processed and was successful
public LoggedOut logged_out; // Called when logout has been processded. Either called explicitly if you initialize a logout operation, or implicitly if there is a permanent connection error.
public Callback metadata_updated; // Called whenever metadata has been updated. If you have metadata cached outside of libspotify, you should purge your caches and fetch new versions.
public ConnectionError connection_error; // Called when there is a connection error, and the library has problems reconnecting to the Spotify service. Could be called multiple times (as long as the problem is present)
public Callback message_to_user; // Called when the acces point wants to display a message to the user. In the desktop client, these are shown in a blueish toolbar just below the search box.
public Callback notify_main_thread; // Called when processing needs to take place on the main thread. You need to call sp_session_process_events() in the main thread to get libspotify to do more work. Failure to do so may cause request timeouts, or a lost connections.
public Callback music_delivery; // Called when there is decompressed audio data available.
public Callback play_token_lost; // Music has been paused because only one account may play music at the same time.
public Callback log_message; // Logging callback
public Callback end_of_track; // End of track. Called when the currently played track has reached its end.
public Callback streaming_error; // Streaming error. Called when streaming cannot start or continue.
public Callback userinfo_updated; // Called after user info (anything related to sp_user objects) have been updated.
public Callback start_playback; // Called when audio playback should start. For this to work correctly the application must also implement get_audio_buffer_stats(). This function is called from an internal session thread - you need to have proper synchronization. This function must never block.
public Callback stop_playback; // Called when audio playback should stop. For this to work correctly the application must also implement get_audio_buffer_stats(). This function is called from an internal session thread - you need to have proper synchronization. This function must never block.
public Callback get_audio_buffer_stats; // Called to query application about its audio buffer. This function is called from an internal session thread - you need to have proper synchronization! This function must never block.
}
private static final char[] APP_KEY ={/* Appkey here**/;
public static void main(String[] args) throws InterruptedException {
JLibspotify lib = (JLibspotify) Native.loadLibrary("spotify", JLibspotify.class);
sp_session_config cfg = new sp_session_config();
Pointer ptr = new Memory(APP_KEY.length);
ptr.write(0, toBytes(APP_KEY), 0, APP_KEY.length);
cfg.application_key = ptr;
cfg.application_key_size = APP_KEY.length;
sp_session_callbacks sessCallbacks = new sp_session_callbacks();
LoggedIn loggedInCallback = new LoggedIn() {
public void logged_in(sp_session session, int error) {
System.out.println("logged_in() called");
}
};
ConnectionError connectionErrorCallback = new ConnectionError() {
public void connection_error(sp_session session, int error) {
System.out.println("connection_error() called");
}
};
LoggedOut loggedOutCallback = new LoggedOut() {
public void logged_out(sp_session session, int error) {
System.out.println("logged_out() called");
}
};
sessCallbacks.logged_in = loggedInCallback;
sessCallbacks.connection_error = connectionErrorCallback;
sessCallbacks.logged_out = loggedOutCallback;
sessCallbacks.log_message = new Callback() {
public void callback(sp_session session, String message) {
System.out.println("log_message() called:" + message);
}
};
cfg.callbacks = sessCallbacks;
PointerByReference sessionPbr = new PointerByReference();
int error_id = lib.sp_session_create(cfg, sessionPbr); // CRASHES HERE
System.out.println("sp_session_create returned " + error_id);
//
sp_session mySession = new sp_session(sessionPbr.getValue());
error_id = lib.sp_session_login(mySession, "foo", "bar");
System.out.println("sp_session_login returned " + error_id);
Thread.sleep(1000);
}
public static byte[] toBytes(char[] key){
byte[] b = new byte[key.length];
for(int i =0; i < key.length; i++){
if(key[i] > 127){
b[i] = (byte)(key[i] - 256);
}else{
b[i] = (byte)key[i];
}
}
return b;
}
}
Here's a C program which does the same thing (with fewer callbacks -- you'll need to add more). It's for OS X so you may need to change the #include. As I can't get spotify in Australia I can't test it to see whether a successful login hits a callback, but the logging callback works.
#include <stdio.h>
#include <libspotify/api.h>
void SP_CALLCONV log_message(sp_session *session, const char *data) {
fprintf(stderr,"log_message: %s\n", data);
fflush(stderr);
}
void SP_CALLCONV connection_error(sp_session *session, sp_error error) {
fprintf(stderr,"connection_error: %d\n", error);
fflush(stderr);
}
int main(int argc, char** argv) {
static byte APP_KEY[] = {
/*the API key */};
static sp_session_callbacks callbacks;
callbacks.log_message = log_message;
callbacks.connection_error = connection_error;
static sp_session_config cfg;
cfg.callbacks = &callbacks;
cfg.api_version = 7;
cfg.cache_location = ".";
cfg.settings_location = ".";
cfg.user_agent = "jspotify";
cfg.application_key = APP_KEY;
cfg.application_key_size = sizeof(APP_KEY);
sp_session* mySession;
int code = sp_session_create(&cfg, &mySession);
printf("sp_session_create returned %d\n", code);
sp_session_login(mySession, "foo", "bar");
printf("sp_session_login returned %d\n", code);
sleep(10);
}
If the C program calls callbacks which the Java version doesn't, then perhaps there's something wrong with the use of jna -- if not, perhaps there's something more to understand about spotify and when it calls callbacks. I agree that the docs seem to say that a successful login will call a callback, but perhaps they're out of date?

Related

OR-TOOLS EXCEPTION_ACCESS_VIOLATION when running TSP

When I run the TSP algorithm I get a fatal error on the native or-tools library.
There is a small chance to execute the TSP algo with success when running it only one time, but for consecutive executions without a big interval between them, it always happens.
I'm currently running it on Windows 10, but it tested it on Debian and Alpine and the problem still happens.
Here is a preview, but you can see the full log here (each time I get this error the problematic frame is different).
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000002a9e261c007, pid=12012, tid=9116
#
# JRE version: OpenJDK Runtime Environment (14.0.1+7) (build 14.0.1+7)
# Java VM: OpenJDK 64-Bit Server VM (14.0.1+7, mixed mode, sharing, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# J 10298 c2 org.neo4j.kernel.impl.store.LongerShortString.decode([JII)Lorg/neo4j/values/storable/TextValue; (120 bytes) # 0x000002a9e261c007 [0x000002a9e261bb80+0x0000000000000487]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\hugo_\Workspace\Itini\Backend\service-itinerary-builder\hs_err_pid12012.log
Compiled method (c2) 124037 10298 4 org.neo4j.kernel.impl.store.LongerShortString::decode (120 bytes)
total in heap [0x000002a9e261b910,0x000002a9e261cc48] = 4920
relocation [0x000002a9e261ba70,0x000002a9e261bb70] = 256
main code [0x000002a9e261bb80,0x000002a9e261c6e0] = 2912
stub code [0x000002a9e261c6e0,0x000002a9e261c6f8] = 24
oops [0x000002a9e261c6f8,0x000002a9e261c708] = 16
metadata [0x000002a9e261c708,0x000002a9e261c770] = 104
scopes data [0x000002a9e261c770,0x000002a9e261ca40] = 720
scopes pcs [0x000002a9e261ca40,0x000002a9e261cb90] = 336
dependencies [0x000002a9e261cb90,0x000002a9e261cb98] = 8
handler table [0x000002a9e261cb98,0x000002a9e261cc28] = 144
nul chk table [0x000002a9e261cc28,0x000002a9e261cc48] = 32
Compiled method (c2) 124056 12326 4 org.neo4j.kernel.impl.newapi.DefaultPropertyCursor::propertyValue (38 bytes)
total in heap [0x000002a9e2cb7410,0x000002a9e2cb88f8] = 5352
relocation [0x000002a9e2cb7570,0x000002a9e2cb7750] = 480
main code [0x000002a9e2cb7760,0x000002a9e2cb8280] = 2848
stub code [0x000002a9e2cb8280,0x000002a9e2cb82c8] = 72
oops [0x000002a9e2cb82c8,0x000002a9e2cb82d8] = 16
metadata [0x000002a9e2cb82d8,0x000002a9e2cb8398] = 192
scopes data [0x000002a9e2cb8398,0x000002a9e2cb8618] = 640
scopes pcs [0x000002a9e2cb8618,0x000002a9e2cb8828] = 528
dependencies [0x000002a9e2cb8828,0x000002a9e2cb8838] = 16
handler table [0x000002a9e2cb8838,0x000002a9e2cb88c8] = 144
nul chk table [0x000002a9e2cb88c8,0x000002a9e2cb88f8] = 48
Java code:
public List<AlgoNode> solve(final Collection<AlgoNode> nodes, final AlgoNode start) {
if (nodes == null || nodes.isEmpty())
return new ArrayList<>();
if (nodes.size() == 1)
return new ArrayList<>(nodes);
// Setup Variables
var list = new ArrayList<>(nodes);
var depot = start == null ? 0 : list.indexOf(start);
var manager = new RoutingIndexManager(list.size(), 1, depot);
var routing = new RoutingModel(manager);
// Define dummy weight function
var transitCallbackIndex = routing.registerTransitCallback((fromIndex, toIndex) -> 1L);
routing.setArcCostEvaluatorOfAllVehicles(transitCallbackIndex);
// Solve
var parameters = main.defaultRoutingSearchParameters().toBuilder();
parameters.setFirstSolutionStrategy(FirstSolutionStrategy.Value.PATH_CHEAPEST_ARC);
var solution = routing.solveWithParameters(parameters.build()); // Problematic line
return new ArrayList<>(); // Dummy return
}
I also tryied making the method syncronized, using a lock and calling closeModel() after running the TSP, but no lucky.
seems related to https://github.com/google/or-tools/issues/2091
Please, don't hesitate to open a github issue with all this information...

Heap Corruption In C When Using DLL With JNA

I am using C language Native API callbacks with DLL files. When we are calling callback first time everything is working fine but on second call I am getting heap corruption error and JVM is getting crashed.
In the native code the memory allocated in first call is being released and then is being used in second call again and during memory allocation in second call JVM is being crashed. But on the same place when in second call new memory pointer is used rather than the one which was used in previous call I am not getting this heap corruption error.
As this callback is called many times I can not keep on allocating new space every time. In below logs I am getting error as INVALID_POINTER_READ.
I am not able to understand what is the reason behind it and how this can be fixed. When same DLL is used with JNA it's working fine.
Java/JNA Code:
Setting Hook:
final PropertyCallBack callback = new PropertyCallBack();
final int setHookStatus = callback.setHook();
private static CALLBACK callback;
public int setHook() {
if (callback != null) {
return 0;
}
synchronized (this) {
if (callback == null) {
callback = new CALLBACK();
return callback.setHook();
}
}
return 0;
}
Callback Method Called From Native:
#Override
public int PropertyHook(final DESTINATION dest, final BACSTAC_READ_INFO.ByReference info) {
final PROPERTY_CONTENTS.ByReference content = new PROPERTY_CONTENTS.ByReference();
final BUFFER.ByReference buffer = new BUFFER.ByReference();
// Memory assign
final int bufferSize = 1048;
buffer.pBuffer = new Memory(bufferSize);
buffer.nBufferSize = bufferSize;
content.tag = "INVALID";
content.buffer = buffer;
content.nElements = 0;
Pointer dev = NativeLibrary.INSTANCE.Call_1();
Pointer obj = null;
if (dev != null) {
obj = NativeLibrary.INSTANCE.call_2(dev, info.objectID);
}
final int readDbStatus = NativeLibrary.INSTANCE.call_3(obj, info.prop, info.index, content, null);
final int responseStatus = NativeLibrary.INSTANCE.call_4(dest, info, content);
return 0;
}
When I analyzed heap dump with windbg I am getting below details:
This dump file has an exception of interest stored in it.
The stored exception information can be accessed via .ecxr.
(6201c.5ef10): Access violation - code c0000005 (first/second chance not available)
For analysis of this file, run !analyze -v
ntdll!NtWaitForMultipleObjects+0x14:
00007ffa`46deb4f4 c3 ret
0:026> !analyze -v
*******************************************************************************
* *
* Exception Analysis *
* *
*******************************************************************************
*** WARNING: Unable to verify checksum for srv.dll
DEBUG_FLR_EXCEPTION_CODE(c0000374) and the ".exr -1" ExceptionCode(c0000005) don't match
KEY_VALUES_STRING: 1
Key : AV.Fault
Value: Read
Key : Timeline.Process.Start.DeltaSec
Value: 46
PROCESSES_ANALYSIS: 1
SERVICE_ANALYSIS: 1
STACKHASH_ANALYSIS: 1
TIMELINE_ANALYSIS: 1
Timeline: !analyze.Start
Name: <blank>
Time: 2019-12-02T11:13:41.439Z
Diff: 3429439 mSec
Timeline: Dump.Current
Name: <blank>
Time: 2019-12-02T10:16:32.0Z
Diff: 0 mSec
Timeline: Process.Start
Name: <blank>
Time: 2019-12-02T10:15:46.0Z
Diff: 46000 mSec
DUMP_CLASS: 2
DUMP_QUALIFIER: 400
CONTEXT: (.ecxr)
rax=0000000000030000 rbx=000000002b200000 rcx=0000000000000303
rdx=0000000000000003 rsi=01fda8c00000ed00 rdi=000000002b223ef0
rip=00007ffa46d6cb7a rsp=000000002b8ff500 rbp=0000000000000008
r8=0000000000000028 r9=0000000000000030 r10=00000000014da2d0
r11=00000000014e2ef0 r12=0000000000000001 r13=0000000000000003
r14=000000002b223ee0 r15=000000000600c1ba
iopl=0 nv up ei pl zr na po nc
cs=0033 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010246
ntdll!RtlpAllocateHeap+0xdaa:
00007ffa`46d6cb7a 498b07 mov rax,qword ptr [r15] ds:00000000`0600c1ba=????????????????
Resetting default scope
FAULTING_IP:
ntdll!RtlpAllocateHeap+daa
00007ffa`46d6cb7a 498b07 mov rax,qword ptr [r15]
EXCEPTION_RECORD: (.exr -1)
ExceptionAddress: 00007ffa46d6cb7a (ntdll!RtlpAllocateHeap+0x0000000000000daa)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 0000000000000000
Parameter[1]: 000000000600c1ba
Attempt to read from address 000000000600c1ba
DEFAULT_BUCKET_ID: HEAP_CORRUPTION
PROCESS_NAME: javaw.exe
FOLLOWUP_IP:
ntdll!RtlpAllocateHeap+daa
00007ffa`46d6cb7a 498b07 mov rax,qword ptr [r15]
READ_ADDRESS: 000000000600c1ba
ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%p referenced memory at 0x%p. The memory could not be %s.
EXCEPTION_CODE: (NTSTATUS) 0xc0000374 - A heap has been corrupted.
EXCEPTION_CODE_STR: c0000005
EXCEPTION_PARAMETER1: 0000000000000000
EXCEPTION_PARAMETER2: 000000000600c1ba
WATSON_BKT_PROCSTAMP: 5d1dea24
WATSON_BKT_PROCVER: 8.0.2210.11
PROCESS_VER_PRODUCT: Java(TM) Platform SE 8
WATSON_BKT_MODULE: ntdll.dll
WATSON_BKT_MODSTAMP: 7f828745
WATSON_BKT_MODOFFSET: 1cb7a
WATSON_BKT_MODVER: 10.0.17134.799
MODULE_VER_PRODUCT: Microsoft® Windows® Operating System
BUILD_VERSION_STRING: 17134.1.amd64fre.rs4_release.180410-1804
MODLIST_WITH_TSCHKSUM_HASH: f06ad8a6a7f7267c783c08e3a62df4696020d52f
MODLIST_SHA1_HASH: cdafa8057ac19b1a3608c439ebbfa992407212d6
NTGLOBALFLAG: 0
PROCESS_BAM_CURRENT_THROTTLED: 0
PROCESS_BAM_PREVIOUS_THROTTLED: 0
APPLICATION_VERIFIER_FLAGS: 0
DUMP_FLAGS: 94
DUMP_TYPE: 1
ANALYSIS_SESSION_HOST: MD2E86EC
ANALYSIS_SESSION_TIME: 12-02-2019 16:43:41.0439
ANALYSIS_VERSION: 10.0.18362.1 x86fre
THREAD_ATTRIBUTES:
ADDITIONAL_DEBUG_TEXT: Enable Pageheap/AutoVerifer ; Followup set based on attribute [Is_ChosenCrashFollowupThread] from Frame:[0] on thread:[PSEUDO_THREAD]
FAULTING_THREAD: 0005ef10
THREAD_SHA1_HASH_MOD_FUNC: 5d531e271dfb1ef7af4984c7ee0dd671c07337f5
THREAD_SHA1_HASH_MOD_FUNC_OFFSET: d858fa5fb04738fbbbbb9e4df89e26d53dc74794
OS_LOCALE: ENU
BUGCHECK_STR: APPLICATION_FAULT_INVALID_POINTER_READ_HEAP_CORRUPTION
PRIMARY_PROBLEM_CLASS: APPLICATION_FAULT
PROBLEM_CLASSES:
ID: [0n262]
Type: [HEAP_CORRUPTION]
Class: Primary
Scope: DEFAULT_BUCKET_ID (Failure Bucket ID prefix)
BUCKET_ID
Name: Add
Data: Omit
PID: [0x6201c]
TID: [0x5ef10]
Frame: [0] : ntdll!RtlpAllocateHeap
ID: [0n262]
Type: [HEAP_CORRUPTION]
Class: Primary
Scope: BUCKET_ID
Name: Add
Data: Omit
PID: [0x6201c]
TID: [0x5ef10]
Frame: [0] : ntdll!RtlpAllocateHeap
ID: [0n313]
Type: [#ACCESS_VIOLATION]
Class: Addendum
Scope: BUCKET_ID
Name: Omit
Data: Omit
PID: [Unspecified]
TID: [0x5ef10]
Frame: [0] : ntdll!RtlpAllocateHeap
ID: [0n285]
Type: [INVALID_POINTER_READ]
Class: Primary
Scope: BUCKET_ID
Name: Add
Data: Omit
PID: [Unspecified]
TID: [0x5ef10]
Frame: [0] : ntdll!RtlpAllocateHeap
LAST_CONTROL_TRANSFER: from 00007ffa46d69725 to 00007ffa46d6cb7a
STACK_TEXT:
00000000`00000000 00000000`00000000 heap_corruption!javaw.exe+0x0
THREAD_SHA1_HASH_MOD: ca4e26064d24ef7512d2e94de5a93c38dbe82fe9
SYMBOL_STACK_INDEX: 0
SYMBOL_NAME: heap_corruption!javaw.exe
FOLLOWUP_NAME: MachineOwner
MODULE_NAME: heap_corruption
IMAGE_NAME: heap_corruption
DEBUG_FLR_IMAGE_TIMESTAMP: 0
STACK_COMMAND: ** Pseudo Context ** ManagedPseudo ** Value: a3807e8 ** ; kb
FAILURE_BUCKET_ID: HEAP_CORRUPTION_c0000005_heap_corruption!javaw.exe
BUCKET_ID: APPLICATION_FAULT_INVALID_POINTER_READ_HEAP_CORRUPTION_heap_corruption!javaw.exe
FAILURE_EXCEPTION_CODE: c0000005
FAILURE_IMAGE_NAME: heap_corruption
BUCKET_ID_IMAGE_STR: heap_corruption
FAILURE_MODULE_NAME: heap_corruption
BUCKET_ID_MODULE_STR: heap_corruption
FAILURE_FUNCTION_NAME: javaw.exe
BUCKET_ID_FUNCTION_STR: javaw.exe
BUCKET_ID_OFFSET: 0
BUCKET_ID_MODTIMEDATESTAMP: 0
BUCKET_ID_MODCHECKSUM: 0
BUCKET_ID_MODVER_STR: 0.0.0.0
BUCKET_ID_PREFIX_STR: APPLICATION_FAULT_INVALID_POINTER_READ_
FAILURE_PROBLEM_CLASS: APPLICATION_FAULT
FAILURE_SYMBOL_NAME: heap_corruption!javaw.exe
WATSON_STAGEONE_URL: http://watson.microsoft.com/StageOne/javaw.exe/8.0.2210.11/5d1dea24/ntdll.dll/10.0.17134.799/7f828745/c0000005/0001cb7a.htm?Retriage=1
TARGET_TIME: 2019-12-02T10:16:32.000Z
OSBUILD: 17134
OSSERVICEPACK: 753
SERVICEPACK_NUMBER: 0
OS_REVISION: 0
SUITE_MASK: 256
PRODUCT_TYPE: 1
OSPLATFORM_TYPE: x64
OSNAME: Windows 10
OSEDITION: Windows 10 WinNt SingleUserTS
USER_LCID: 0
OSBUILD_TIMESTAMP: unknown_date
BUILDDATESTAMP_STR: 180410-1804
BUILDLAB_STR: rs4_release
BUILDOSVER_STR: 10.0.17134.1.amd64fre.rs4_release.180410-1804
ANALYSIS_SESSION_ELAPSED_TIME: 307a
ANALYSIS_SOURCE: UM
FAILURE_ID_HASH_STRING: um:heap_corruption_c0000005_heap_corruption!javaw.exe
FAILURE_ID_HASH: {ddc2b378-b1e1-2aec-adc8-f11b7a5773a9}
Any help in fix/debug will be highly appreciated.
I got the solution of to prevent above heap corruption by calling NativeLibrary methods of PropertyHook in another thread. Somehow by calling NativeLibrary methods in different thread heap is not getting corrupted and sub-sequently JVM is not being crashed.

Is it problematic to call dlls out of Java with another C-Runtime (msvcr90.dll) than Java (msvcr100.dll)?

I'm calling dlls out of Java using JNA.
This works most of the time, but sometimes a Memory Access Exception is thrown.
I found out that the jvm.exe runs with the msvcr100.dll and the dlls are running on the msvcr90.dll. Can this lead to problems?
Java Interface Code:
public interface FooLibInterface extends StdCallLibrary {
FltLibInterface INSTANCE = (FooLibInterface) Native.loadLibrary("C:\\dlls\\FooLibWrapper.dll", FooLibInterface.class);
NativeLong wrapedFooInterface(long id, PointerByReference inDataArray, long inItems, PointerByReference outDataArray, NativeLongByReference outItems, DoubleByReference outParX);
}
Java call:
synchronized (lock) {
long id = 123;
PointerByReference inputArray = new PointerByReference();
Memory buffer = new Memory(data.length * 8);
buffer.write(0, data, 0, data.length);
inputArray.setValue(buffer);
PointerByReference outputArray = new PointerByReference();
NativeLongByReference outItems = new NativeLongByReference();
DoubleByReference outParX = new DoubleByReference();
NativeLong excRet = ffltLib.wrapedProfileFilterInterface(id, inputArray, data.length, outputArray, outItems, outParX);
items = outItems.getValue().intValue();
double parX = outParX.getValue();
newdata = new double[ret.itemsX];
for (int x = 0; x < items; x += 1) {
newdata [x] = outputArray.getValue().getDouble(x * 8);
}
ffltLib.freemem();
}
c-Header:
#pragma pack(1)
#ifndef __FOOLIBWRAPPER_H__
#define __FOOLIBWRAPPER_H__
#include <iostream>
#include <windows.h>
#include <string.h>
/* To use this exported function of dll, include this header
* in your project.
*/
//Import Strukturen
typedef struct {
double *Data;
long Items;
double ParX;
} TNativeFoo;
typedef void (WINAPI *FOOINTERFACE) (LONGLONG *id, void *input, void *output);
extern "C" __declspec(dllexport) long wrapedFooInterface(LONGLONG id, double** inDataArray, LONGLONG inItems, double** outDataArray, LONGLONG* outItems, double* outParX)
extern "C" __declspec(dllexport) void freemem();
#endif // __FOOLIBWRAPPER_H__
C-Code:
extern "C" __declspec(dllexport) long wrapedFooInterface(LONGLONG id, double** inDataArray, LONGLONG inItems, double** outDataArray, LONGLONG* outItems, double* outParX)
{
long i;
HINSTANCE hGetProcIDDLL;
FARPROC lpfnFooInterfaceProcAddress;
FOOINTERFACE fncFooInterface;
long internID(0);
memRegister.getcsmmemid(&internID);
memRegister.getcsmmemid();
hGetProcIDDLL = LoadLibraryA(LibaryPath.c_str());
lpfnFooInterfaceProcAddress = GetProcAddress(HMODULE (hGetProcIDDLL),"FooInterface");
fncFooInterface = FOOINTERFACE(lpfnFooInterfaceProcAddress);
OutputFoo.Data = (double *) memRegister.getmem(internID, inItems, sizeof(double));
InputFoo.Data = (double *) memRegister.getmem(internID, inItems, sizeof(double));
for (i=0L; i<inItems; i++)
InputFoo.Data[i]=inDataArray[0][i];
InputFoo.Items = OutputFoo.Items = inItems;
InputFoo.ParX = OutputFoo.ParX = inParX;
fncFooInterface(&id, &InputFoo, &OutputFoo);
outDataArray[0] = (double *) memRegister.getmem(OutputFoo.Items, sizeof(double));
for(long i=0;i<OutputFoo.Items;i++)
{
outDataArray[0][i]=OutputFoo.Data[i];
}
*outItems = OutputFoo.Items;
*outParX = OutputFoo.ParX;
memRegister.freemem(internID);
FreeLibrary(hGetProcIDDLL);
return 0;
}
Exception:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d316065, pid=10940, tid=11020
#
# JRE version: 7.0_09-b05
# Java VM: Java HotSpot(TM) Client VM (23.5-b02 mixed mode windows-x86 )
# Problematic frame:
# C [FltLibWrapper.dll+0x16065] wrapedProfileFilterInterface+0x105
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Stack:
Stack: [0x6a5e0000,0x6a6e0000], sp=0x6a6de620, free space=1017k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [FooLibWrapper.dll+0x16065] wrapedFooInterface+0x105
C [jna6443424344288876112.dll+0xcc77] Java_com_sun_jna_Native_initialize_1ffi_1type+0x38b7
C [jna6443424344288876112.dll+0xc78a] Java_com_sun_jna_Native_initialize_1ffi_1type+0x33ca
C [jna6443424344288876112.dll+0x4561] Java_com_sun_jna_Pointer__1getString+0xa31
C [jna6443424344288876112.dll+0x4cae] Java_com_sun_jna_Function_invokeVoid+0x2e
j com.sun.jna.Function.invokeVoid(I[Ljava/lang/Object;)V+0
j com.sun.jna.Function.invoke([Ljava/lang/Object;Ljava/lang/Class;Z)Ljava/lang/Object;+45
j com.sun.jna.Function.invoke(Ljava/lang/Class;[Ljava/lang/Object;Ljava/util/Map;)Ljava/lang/Object;+214
j com.sun.jna.Library$Handler.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+341
j $Proxy35.wrapedFoorInterface(JLcom/sun/jna/ptr/PointerByReference;JDDLcom/sun/jna/ptr/PointerByReference;Lcom/sun/jna/ptr/NativeLongByReference;Lcom/sun/jna/ptr/DoubleByReference;Lcom/sun/jna/ptr/DoubleByReference;Lcom/sun/jna/ptr/NativeLongByReference;D)V+86
J WrapperStructure.FooLibWrapper.fooInterface(LWrapperStructure/Foo;JD)LWrapperStructure/Foo;
...
j Routes$$anonfun$routes$1$$anonfun$apply$75$$anonfun$apply$76.apply()Lplay/mvc/Result;+38
j Routes$$anonfun$routes$1$$anonfun$apply$75$$anonfun$apply$76.apply()Ljava/lang/Object;+1
j play.core.Router$HandlerInvoker$$anon$5$$anon$1.invocation()Lplay/mvc/Result;+4
j play.core.j.JavaAction$$anon$1.call(Lplay/mvc/Http$Context;)Lplay/mvc/Result;+13
j play.GlobalSettings$1.call(Lplay/mvc/Http$Context;)Lplay/mvc/Result;+5
j controllers.Annotations.CurrentUser.call(Lplay/mvc/Http$Context;)Lplay/mvc/Result;+248
j play.core.j.JavaAction$class.apply(Lplay/core/j/JavaAction;Lplay/api/mvc/Request;)Lplay/api/mvc/Result;+368
j play.core.Router$HandlerInvoker$$anon$5$$anon$1.apply(Lplay/api/mvc/Request;)Lplay/api/mvc/Result;+2
j play.core.ActionInvoker$$anonfun$receive$1$$anonfun$6.apply()Lplay/api/mvc/Result;+8
j play.core.ActionInvoker$$anonfun$receive$1$$anonfun$6.apply()Ljava/lang/Object;+1
j play.utils.Threads$.withContextClassLoader(Ljava/lang/ClassLoader;Lscala/Function0;)Ljava/lang/Object;+16
j play.core.ActionInvoker$$anonfun$receive$1.apply(Ljava/lang/Object;)V+148
j play.core.ActionInvoker$$anonfun$receive$1.apply(Ljava/lang/Object;)Ljava/lang/Object;+2
j akka.actor.Actor$class.apply(Lakka/actor/Actor;Ljava/lang/Object;)V+25
j play.core.ActionInvoker.apply(Ljava/lang/Object;)V+2
j akka.actor.ActorCell.invoke(Lakka/dispatch/Envelope;)V+37
j akka.dispatch.Mailbox.processMailbox(IJ)V+24
j akka.dispatch.Mailbox.run()V+20
j akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec()Z+6
J akka.jsr166y.ForkJoinTask.doExec()I
v ~StubRoutines::call_stub
V [jvm.dll+0x12a39a]
V [jvm.dll+0x1d978e]
V [jvm.dll+0x12a583]
V [jvm.dll+0x12a5e7]
V [jvm.dll+0xd315f]
V [jvm.dll+0x14a697]
V [jvm.dll+0x14a800]
V [jvm.dll+0x17efe9]
C [msvcr100.dll+0x5c6de] endthreadex+0x3a
C [msvcr100.dll+0x5c788] endthreadex+0xe4
C [KERNEL32.DLL+0x2850d] BaseThreadInitThunk+0xe
C [ntdll.dll+0x5bf39] RtlInitializeExceptionChain+0x85
C [ntdll.dll+0x5bf0c] RtlInitializeExceptionChain+0x58
DLLs:
0x00030000 - 0x0005f000 C:\Program Files (x86)\Java\jdk1.7.0_09_32Bit\bin\java.exe
...
0x6d300000 - 0x6d326000 C:\dlls\FooLibWrapper.dll
0x6cf50000 - 0x6d026000 C:\Windows\WinSxS\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2\MSVCP90D.dll
0x6ce20000 - 0x6cf43000 C:\Windows\WinSxS\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.21022.8_none_96748342450f6aa2\MSVCR90D.dll
0x675a0000 - 0x675d4000 C:\dlls\FooLib.dll
...
Heap:
def new generation total 157376K, used 101422K [0x047f0000, 0x0f2b0000, 0x19d40000)
eden space 139904K, 61% used [0x047f0000, 0x09bb6fd8, 0x0d090000)
from space 17472K, 89% used [0x0d090000, 0x0dfd49f8, 0x0e1a0000)
to space 17472K, 0% used [0x0e1a0000, 0x0e1a0000, 0x0f2b0000)
tenured generation total 349568K, used 67082K [0x19d40000, 0x2f2a0000, 0x447f0000)
the space 349568K, 19% used [0x19d40000, 0x1dec28a0, 0x1dec2a00, 0x2f2a0000)
compacting perm gen total 57600K, used 57590K [0x447f0000, 0x48030000, 0x547f0000)
the space 57600K, 99% used [0x447f0000, 0x4802da78, 0x4802dc00, 0x48030000)
No shared spaces configured.
Args:
VM Arguments:
jvm_args: -Dfile.encoding=UTF8 -Dsbt.boot.properties=file:///E:/play-2.0.4/framework/sbt/sbt.boot.properties -Dsbt.log.noformat=true -Dsbt.global.plugins="C:\Users\TimoW_000\AppData\Local\Temp\sbt-global-plugin233941470253421253stub" -Dplay.version=2.0.4 -Dsbt.ivy.home=E:\play-2.0.4\repository -Dplay.home=E:\play-2.0.4\framework -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M
java_command: xsbt.boot.Boot run
Launcher Type: SUN_STANDARD
Environment Variables:
CLASSPATH=.;C:\Program Files (x86)\Java\jre7_32bit\lib\ext\QTJava.zip
PATH=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.1\bin\..\.\bin;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.1\bin\..\.\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;E:\play-2.0.4\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Java\jdk1.7.0_09_32Bit\bin;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\TortoiseGit\bin;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\OpenSSH\bin;c:\program files (x86)\jetbrains\intellij idea 12.1\jre\jre\bin;c:\program files (x86)\jetbrains\intellij idea 12.1\jre\jre\bin
USERNAME=TimoW_000
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
System:
OS: Windows 8 , 64 bit Build 9200
CPU:total 4 (4 cores per cpu, 1 threads per core) family 6 model 42 stepping 7, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, tsc, tscinvbit
Memory: 4k page, physical 8361544k(2628436k free), swap 11376200k(4311964k free)
vm_info: Java HotSpot(TM) Client VM (23.5-b02) for windows-x86 JRE (1.7.0_09-b05), built on Sep 24 2012 22:01:33 by "java_re" with unknown MS VC++:1600
time: Fri Sep 27 12:32:29 2013
elapsed time: 122 seconds

Tomcat crashes when calling JNI dll in windows 7

I have a Java web application that uses tomcat 7 and that calls a JNI dll to decrypt some data using Openssl EVP.
When running on windows XP all works fine, but when I try to run it in windows 7 it crashes.
the tomcat stdout.log :
2013-07-07 14:23:33 Commons Daemon procrun stdout initialized
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x77b42b79, pid=3576, tid=1528
#
# JRE version: 6.0_18-b07
# Java VM: Java HotSpot(TM) Client VM (16.0-b13 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [ntdll.dll+0x52b79]
#
# An error report file with more information is saved as:
# C:\Windows\system32\hs_err_pid3576.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
applicationContext.xml]
[2013-07-07 14:23:52,025] INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from ServletContext resource [/WEB-INF/conf/spring/applicationContext-dataSource.xml]
[2013-07-07 14:23:52,119] INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from ServletContext resource [/WEB-INF/conf/spring/applicationContext-manageable.xml]
[2013-07-07 14:23:52,228] INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from ServletContext resource [/WEB-INF/conf/spring/applicationContext-security.xml]
[2013-07-07 14:23:52,930] INFO [org.springframework.security.core.SpringSecurityCoreVersion] - You are running with Spring Security Core 3.0.5.RELEASE
[2013-07-07 14:23:52,930] INFO [org.springframework.security.config.SecurityNamespaceHandler] - Spring Security 'config' module version is 3.0.5.RELEASE
[2013-07-07 14:23:53,148] INFO [org.springframework.security.config.http.HttpSecurityBeanDefinitionParser] - ncyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1800, <org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0>, order = 1900]
the file C:\Windows\system32\hs_err_pid3576.log indicates that the function called from the jni dll is the source of error :
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x77b42b79, pid=3576, tid=1528
#
# JRE version: 6.0_18-b07
# Java VM: Java HotSpot(TM) Client VM (16.0-b13 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [ntdll.dll+0x52b79]
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
--------------- T H R E A D ---------------
Current thread (0x039ab000): JavaThread "Thread-2" daemon [_thread_in_vm, id=1528, stack(0x03bf0000,0x03c60000)]
....
Stack: [0x03bf0000,0x03c60000], sp=0x03c5e74c, free space=1b903c5e268k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [ntdll.dll+0x52b79]
C [ntdll.dll+0x52e7d]
C [ntdll.dll+0x52d68]
C [kernel32.dll+0x4f1ac]
C [MSVCR71.dll+0x218a]
V [jvm.dll+0x105036]
C [myDLL.dll+0x1910]
j myApp.d([B)[B+0
j myApp.dec([B)[B+2
j org.apache.catalina.h.WebappsClassLoader.findClassInternal(Ljava/lang/String;)Ljava/lang/Class;+425
j org.apache.catalina.loader.WebappClassLoader.findClass(Ljava/lang/String;)Ljava/lang/Class;+301
j org.apache.catalina.h.WebappsClassLoader.loadClass(Ljava/lang/String;Z)Ljava/lang/Class;+451
j org.apache.catalina.h.WebappsClassLoader.loadClass(Ljava/lang/String;)Ljava/lang/Class;+3
j org.springframework.util.ClassUtils.forName(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/Class;+177
j org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(Ljava/lang/ClassLoader;)Ljava/lang/Class;+13
j org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(Lorg/springframework/beans/factory/support/RootBeanDefinition;[Ljava/lang/Class;)Ljava/lang/Class;+96
j org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(Lorg/springframework/beans/factory/support/RootBeanDefinition;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/Class;+42
j org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(Ljava/lang/String;Lorg/springframework/beans/factory/support/RootBeanDefinition;[Ljava/lang/Class;)Ljava/lang/Class;+23
j org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(Ljava/lang/String;Lorg/springframework/beans/factory/support/RootBeanDefinition;)Z+13
j org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(Ljava/lang/Class;ZZ)[Ljava/lang/String;+105
j org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(Ljava/lang/Class;ZZ)Ljava/util/Map;+4
j org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(Lorg/springframework/beans/factory/config/ConfigurableListableBeanFactory;)V+126
j org.springframework.context.support.AbstractApplicationContext.refresh()V+28
j org.springframework.web.context.ContextLoader.createWebApplicationContext(Ljavax/servlet/ServletContext;Lorg/springframework/context/ApplicationContext;)Lorg/springframework/web/context/WebApplicationContext;+245
j org.springframework.web.context.ContextLoader.initWebApplicationContext(Ljavax/servlet/ServletContext;)Lorg/springframework/web/context/WebApplicationContext;+69
j org.springframework.web.context.ContextLoaderListener.contextInitialized(Ljavax/servlet/ServletContextEvent;)V+28
j org.apache.catalina.core.StandardContext.listenerStart()Z+523
j org.apache.catalina.core.StandardContext$1.call()Ljava/lang/Boolean;+12
j org.apache.catalina.core.StandardContext$1.call()Ljava/lang/Object;+1
j java.util.concurrent.FutureTask$Sync.innerRun()V+30
j java.util.concurrent.FutureTask.run()V+4
j java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Ljava/lang/Runnable;)V+59
j java.util.concurrent.ThreadPoolExecutor$Worker.run()V+28
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub
V [jvm.dll+0xf072c]
V [jvm.dll+0x17fd51]
V [jvm.dll+0xf08f7]
V [jvm.dll+0xf096d]
V [jvm.dll+0x11a4c0]
V [jvm.dll+0x1dd924]
V [jvm.dll+0x17f9cc]
C [MSVCR71.dll+0x9565]
C [kernel32.dll+0x51174]
C [ntdll.dll+0x5b3f5]
C [ntdll.dll+0x5b3c8]
....
--------------- S Y S T E M ---------------
OS: Windows 7 Build 7600
CPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 23 stepping 10, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1
Memory: 4k page, physical 2056808k(1150444k free), swap 4113616k(2684008k free)
vm_info: Java HotSpot(TM) Client VM (16.0-b13) for windows-x86 JRE (1.6.0_18-b07), built on Dec 17 2009 13:35:55 by "java_re" with MS VC++ 7.1 (VS2003)
time: Sun Jul 07 14:23:53 2013
elapsed time: 19 seconds
The jni dll name is : myDLL.dll
and the function is : myApp.d()
Here is the myApp.d() function in the c program that generates the dll :
JNIEXPORT jbyteArray JNICALL Java_myApp_d(JNIEnv *env, jobject obj, jbyteArray b)
{
EVP_CIPHER_CTX en, de;
// get length of bytes
int srcLen=(*env)->GetArrayLength(env, b);
//convert jbyteArray to byte []
jbyte data[srcLen];
(*env)->GetByteArrayRegion(env, b, 0, srcLen, data);
(*env)->ReleaseByteArrayElements(env, b, data , 0);
unsigned int salt[] = {12345, 54321};
unsigned char key_data[16]={ 'A','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p'};
int key_data_len = 16;
if (aes_init(key_data, key_data_len, (unsigned char *)&salt, &en, &de))
{
printf("Couldn't initialize AES cipher\n");
return -1;
}
unsigned char* indata=(unsigned char*)data;
char *plaintext;
int olen, len;
int j;
char tampon[16];
for(j=0; j<16; j++)
{
tampon[j]=indata[j];
}
int desLen;
sscanf(tampon,"%d",&desLen);
unsigned char indataB[srcLen-16];
for(j=0; j<srcLen-16; j++)
{
indataB[j]=indata[16+j];
}
olen = len = srcLen-16+1;
plaintext = (char *)aes_decrypt(&de, indataB, &len);
jbyteArray bArray = (*env)->NewByteArray(env, desLen);
jboolean isCopy = JNI_TRUE;
jbyte* decrypteddata = (jbyte *)(*env)->GetByteArrayElements(env, bArray, &isCopy);
memcpy(decrypteddata, plaintext, desLen);
(*env)->ReleaseByteArrayElements(env, bArray, decrypteddata, 0);
free(plaintext);
free(decrypteddata);
EVP_CIPHER_CTX_cleanup(&en);
EVP_CIPHER_CTX_cleanup(&de);
return bArray;
(*env)->DeleteLocalRef(env, bArray );
}
This function uses these tow functions:
int aes_init(unsigned char *key_data, int key_data_len, unsigned char *salt, EVP_CIPHER_CTX *e_ctx,
EVP_CIPHER_CTX *d_ctx)
{
int i, nrounds = 5;
unsigned char key[16], iv[16];
/*
* Gen key & IV for AES 128 CBC mode. A SHA1 digest is used to hash the supplied key material.
* nrounds is the number of times the we hash the material. More rounds are more secure but
* slower.
*/
i = EVP_BytesToKey(EVP_aes_128_cbc(), EVP_sha1(), salt, key_data, key_data_len, nrounds, key, iv);
if (i != 16)
{
printf("Key size is %d bits - should be 128 bits\n", i);
return -1;
}
EVP_CIPHER_CTX_init(e_ctx);
EVP_EncryptInit_ex(e_ctx, EVP_aes_128_cbc(), NULL, key, iv);
EVP_CIPHER_CTX_init(d_ctx);
EVP_DecryptInit_ex(d_ctx, EVP_aes_128_cbc(), NULL, key, iv);
return 0;
}
unsigned char *aes_decrypt(EVP_CIPHER_CTX *e, unsigned char *ciphertext, int *len)
{
/* because we have padding ON, we must allocate an extra cipher block size of memory */
int p_len = *len, f_len = 0;
unsigned char *plaintext = malloc(p_len + AES_BLOCK_SIZE+1);
EVP_DecryptInit_ex(e, NULL, NULL, NULL, NULL);
EVP_DecryptUpdate(e, plaintext, &p_len, ciphertext, *len);
EVP_DecryptFinal_ex(e, plaintext+p_len, &f_len);
*len = p_len + f_len;
return plaintext;
}
I'm suspecting the this portion that permits to copy data from char* to jbytearray :
jbyte* decrypteddata = (jbyte *)(*env)->GetByteArrayElements(env, bArray, &isCopy);
memcpy(decrypteddata, plaintext, desLen);
(*env)->ReleaseByteArrayElements(env, bArray, decrypteddata, 0);
I tried to replace GetByteArrayElements by GetPrimitiveArrayCritical and ReleaseByteArrayElements by ReleasePrimitiveArrayCritical with no success.
[SOLVED]
As I supposed in my question, the problem was caused by the call to those tow JNI functions :
(*env)->GetByteArrayRegion(env, b, 0, srcLen, data);
(*env)->ReleaseByteArrayElements(env, b, data , 0);
I replaced them with :
jbyte* d = (*env)->GetByteArrayElements(env, b, &isCopyS);
int i;
for(i = 0; i < srcLen; i++)
{
data[i] = d[i];
}
(*env)->ReleaseByteArrayElements(env, b, d, JNI_ABORT);
Now It works both in Windows XP and Windows 7.

Fatal Error has been detected by java runtime environment.... cannot understand why?

My code is given below. Its a program that adds leaves to the database.I am getting the Fatal Error has been detected by java runtime environment and I am not understanding why. I am new to Java, so I am very confused about this. Can anybody tell me why is this happening?
I am putting up the error file as well. I tried understanding that too but couldn't find where is the error located.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.lang.String;
import java.io.*;
import java.sql.*;
public class AddLeave extends JFrame implements ActionListener
{
JFrame frame;
JPanel panel,panel1;
JLabel empid,name1,name2,department,designation;
JTextField txtempid,txtname1,txtname2,txtdepartment,txtdesignation;
JButton find,ok,cancel;
String txtname1_1 = "";
String txtname2_1 = "";
String txtdepartment_1 = "";
String txtdesignation_1 = "";
String txtempid1="";
Connection conn;
public AddLeave()
{
frame=new JFrame("ADD LEAVE");
frame.setLayout(new BorderLayout());
panel=new JPanel();
panel.setLayout(new GridLayout(5,2,5,5));
panel.setBackground(Color.RED);
panel1=new JPanel();
//panel1.setLayout(new GridLayout(1,3,10,10));
panel1.setBackground(Color.GREEN);
empid=new JLabel("Employee Id:");
name1=new JLabel("First Name:");
name2=new JLabel("Last Name:");
department=new JLabel("Department:");
designation=new JLabel("Designation:");
txtempid = new JTextField();
txtname1 = new JTextField();
txtname1.setEditable(false);
txtname2 = new JTextField();
txtname2.setEditable(false);
txtdepartment = new JTextField();
txtdesignation = new JTextField();
txtdesignation.setEditable(false);
find=new JButton("FIND");
find.addActionListener(this);
ok=new JButton("OK");
ok.addActionListener(this);
cancel=new JButton("CANCEL");
cancel.addActionListener(this);
panel.add(empid);
panel.add(txtempid);
panel.add(name1);
panel.add(txtname1);
panel.add(name2);
panel.add(txtname2);
panel.add(department);
panel.add(txtdepartment);
panel.add(designation);
panel.add(txtdesignation);
panel1.add(find);
panel1.add(ok);
panel1.add(cancel);
frame.add(panel,BorderLayout.CENTER);
frame.add(panel1,BorderLayout.SOUTH);
frame.setVisible(true);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
connect();
}
public void connect()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:demo","system","scott");
}
catch(Exception e)
{
System.out.println("Error : "+e);
}
}
public void actionPerformed(ActionEvent event)
{
Object source= event.getSource();
if(source.equals(find))
{
find();
}
if(source.equals(ok))
{
System.out.println("Leave added");
}
if(source.equals(cancel))
{
System.out.println("Canceled");
}
}
public void find()
{
txtempid1=txtempid.getText();
try
{
if(txtempid1.isEmpty())
{
JOptionPane.showMessageDialog(null,"ID REQUIRED!!!","warning",JOptionPane.WARNING_MESSAGE);
}
else
{
Statement stmt = conn.createStatement();
String query = "SELECT * FROM demo WHERE empid='"+txtempid1+"'";
ResultSet rs = stmt.executeQuery(query);
int foundrec = 0;
while (rs.next())
{
txtname1_1 = rs.getString(2);
txtname2_1 = rs.getString(3);
txtdesignation_1 = rs.getString(4);
foundrec =foundrec+ 1;
}
if(foundrec==1)
{
JOptionPane.showMessageDialog(null,"**Record Found**"," Message",JOptionPane.PLAIN_MESSAGE);
txtname1.setText(txtname1_1);
txtname2.setText(txtname2_1);
txtdesignation.setText(txtdesignation_1);
}
else
{
JOptionPane.showMessageDialog(null,"!!!!EMPLOYEE DOES NOT EXIST!!!!"," ERROR",JOptionPane.ERROR_MESSAGE);
}
}
conn.close();
}
catch(Exception e)
{
System.out.println("Error : "+e);
}
}
public static void main(String[] args)
{
new AddLeave();
}
}
this is the error file
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c901010, pid=3052, tid=3732
#
# JRE version: 6.0_31-b05
# Java VM: Java HotSpot(TM) Client VM (20.6-b01 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [ntdll.dll+0x1010]
#
# 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 (0x03054400): JavaThread "AWT-EventQueue-0" [_thread_in_native, id=3732, stack(0x03250000,0x032a0000)]
siginfo: ExceptionCode=0xc0000005, reading address 0x00000018
Registers:
EAX=0x00000004, EBX=0x329ab298, ECX=0x7ffad000, EDX=0x00000004
ESP=0x0329ea48, EBP=0x0329ea60, ESI=0x00000000, EDI=0x03401590
EIP=0x7c901010, EFLAGS=0x00010246
Top of Stack: (sp=0x0329ea48)
0x0329ea48: 74355a16 00000004 034015b4 7432139f
0x0329ea58: 034015b4 03401590 0329ea70 74322c5d
0x0329ea68: 034015b4 03054528 0329ea84 74325fa0
0x0329ea78: 03401590 74350000 0329f1ac 0329eaa0
0x0329ea88: 7432740e 03401590 0329eac0 00000003
0x0329ea98: 0312cd28 03054528 0329eab8 6d36124e
0x0329eaa8: 03401590 0329eac0 03054400 329ab298
0x0329eab8: 0329eb04 00919fc7 00000000 0329eb20
Instructions: (pc=0x7c901010)
0x7c900ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x7c901000: 90 90 90 90 90 64 8b 0d 18 00 00 00 8b 54 24 04
0x7c901010: 83 7a 14 00 75 4f f0 ff 42 04 75 19 8b 41 24 89
0x7c901020: 42 0c c7 42 08 01 00 00 00 33 c0 c2 04 00 8d a4
Register to memory mapping:
EAX=0x00000004 is an unknown value
EBX=0x329ab298 is an oop
{method}
- klass: {other class}
ECX=0x7ffad000 is an unknown value
EDX=0x00000004 is an unknown value
ESP=0x0329ea48 is pointing into the stack for thread: 0x03054400
EBP=0x0329ea60 is pointing into the stack for thread: 0x03054400
ESI=0x00000000 is an unknown value
EDI=0x03401590 is an unknown value
Stack: [0x03250000,0x032a0000], sp=0x0329ea48, free space=314k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [ntdll.dll+0x1010] RtlEnterCriticalSection+0xb
C [ODBC32.dll+0x2c5d] MpHeapAlloc+0x452
C [ODBC32.dll+0x5fa0] SQLSetStmtAttrW+0xfeb
C [ODBC32.dll+0x740e] SQLAllocStmt+0x21
C [JdbcOdbc.dll+0x124e] Java_sun_jdbc_odbc_JdbcOdbc_allocStmt+0x28
j sun.jdbc.odbc.JdbcOdbc.allocStmt(J[B)J+0
j sun.jdbc.odbc.JdbcOdbc.SQLAllocStmt(J)J+47
j sun.jdbc.odbc.JdbcOdbcConnection.createStatement(II)Ljava/sql/Statement;+27
j sun.jdbc.odbc.JdbcOdbcConnection.createStatement()Ljava/sql/Statement;+7
j AddLeave.find()V+37
j AddLeave.actionPerformed(Ljava/awt/event/ActionEvent;)V+17
j javax.swing.AbstractButton.fireActionPerformed(Ljava/awt/event/ActionEvent;)V+84
j javax.swing.AbstractButton$Handler.actionPerformed(Ljava/awt/event/ActionEvent;)V+5
j javax.swing.DefaultButtonModel.fireActionPerformed(Ljava/awt/event/ActionEvent;)V+35
j javax.swing.DefaultButtonModel.setPressed(Z)V+117
j javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Ljava/awt/event/MouseEvent;)V+35
j java.awt.Component.processMouseEvent(Ljava/awt/event/MouseEvent;)V+64
j javax.swing.JComponent.processMouseEvent(Ljava/awt/event/MouseEvent;)V+23
j java.awt.Component.processEvent(Ljava/awt/AWTEvent;)V+81
j java.awt.Container.processEvent(Ljava/awt/AWTEvent;)V+18
j java.awt.Component.dispatchEventImpl(Ljava/awt/AWTEvent;)V+570
j java.awt.Container.dispatchEventImpl(Ljava/awt/AWTEvent;)V+42
j java.awt.Component.dispatchEvent(Ljava/awt/AWTEvent;)V+2
j java.awt.LightweightDispatcher.retargetMouseEvent(Ljava/awt/Component;ILjava/awt/event/Mous eEvent;)V+320
j java.awt.LightweightDispatcher.processMouseEvent(Ljava/awt/event/MouseEvent;)Z+139
j java.awt.LightweightDispatcher.dispatchEvent(Ljava/awt/AWTEvent;)Z+50
j java.awt.Container.dispatchEventImpl(Ljava/awt/AWTEvent;)V+12
j java.awt.Window.dispatchEventImpl(Ljava/awt/AWTEvent;)V+65
j java.awt.Component.dispatchEvent(Ljava/awt/AWTEvent;)V+2
j java.awt.EventQueue.dispatchEventImpl(Ljava/awt/AWTEvent;Ljava/lang/Object;)V+41
j java.awt.EventQueue.access$000(Ljava/awt/EventQueue;Ljava/awt/AWTEvent;Ljava/lang/Object;)V+3
j java.awt.EventQueue$1.run()Ljava/lang/Void;+12
j java.awt.EventQueue$1.run()Ljava/lang/Object;+1
v ~StubRoutines::call_stub
V [jvm.dll+0xfac3b]
V [jvm.dll+0x18c3a1]
V [jvm.dll+0xfacbd]
V [jvm.dll+0xbb654]
C [java.dll+0x102f] Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2Ljava_security_AccessControlContext_2+0x17
j java.security.AccessControlContext$1.doIntersectionPrivilege(Ljava/security/PrivilegedActio n;Ljava/security/AccessControlContext;Ljava/security/AccessControlContext;)Ljava/lang/Objec t;+28
j java.security.AccessControlContext$1.doIntersectionPrivilege(Ljava/security/PrivilegedActio n;Ljava/security/AccessControlContext;)Ljava/lang/Object;+6
j java.awt.EventQueue$2.run()Ljava/lang/Void;+11
j java.awt.EventQueue$2.run()Ljava/lang/Object;+1
v ~StubRoutines::call_stub
V [jvm.dll+0xfac3b]
V [jvm.dll+0x18c3a1]
V [jvm.dll+0xfacbd]
V [jvm.dll+0xbb654]
C [java.dll+0x102f] Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2Ljava_se curity_AccessControlContext_2+0x17
j java.security.AccessControlContext$1.doIntersectionPrivilege(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/security/AccessControlContext;)Ljava/lang/Object;+28
j java.awt.EventQueue.dispatchEvent(Ljava/awt/AWTEvent;)V+73
j java.awt.EventDispatchThread.pumpOneEventForFilters(I)Z+204
j java.awt.EventDispatchThread.pumpEventsForFilter(ILjava/awt/Conditional;Ljava/awt/EventFilter;)V+30
j java.awt.EventDispatchThread.pumpEventsForHierarchy(ILjava/awt/Conditional;Ljava/awt/Component;)V+11
j java.awt.EventDispatchThread.pumpEvents(ILjava/awt/Conditional;)V+4
j java.awt.EventDispatchThread.pumpEvents(Ljava/awt/Conditional;)V+3
j java.awt.EventDispatchThread.run()V+9
v ~StubRoutines::call_stub
V [jvm.dll+0xfac3b]
V [jvm.dll+0x18c3a1]
V [jvm.dll+0xfade1]
V [jvm.dll+0xfae3b]
V [jvm.dll+0xb5569]
V [jvm.dll+0x118f14]
V [jvm.dll+0x140ffc]
C [msvcr71.dll+0x9565] endthreadex+0xa0
C [kernel32.dll+0xb50b] GetModuleFileNameA+0x1b4
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j sun.jdbc.odbc.JdbcOdbc.allocStmt(J[B)J+0
j sun.jdbc.odbc.JdbcOdbc.SQLAllocStmt(J)J+47
j sun.jdbc.odbc.JdbcOdbcConnection.createStatement(II)Ljava/sql/Statement;+27
j sun.jdbc.odbc.JdbcOdbcConnection.createStatement()Ljava/sql/Statement;+7
j AddLeave.find()V+37
j AddLeave.actionPerformed(Ljava/awt/event/ActionEvent;)V+17
j javax.swing.AbstractButton.fireActionPerformed(Ljava/awt/event/ActionEvent;)V+84
j javax.swing.AbstractButton$Handler.actionPerformed(Ljava/awt/event/ActionEvent;)V+5
j javax.swing.DefaultButtonModel.fireActionPerformed(Ljava/awt/event/ActionEvent;)V+35
j javax.swing.DefaultButtonModel.setPressed(Z)V+117
j javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Ljava/awt/event/MouseEvent;)V+35
j java.awt.Component.processMouseEvent(Ljava/awt/event/MouseEvent;)V+64
j javax.swing.JComponent.processMouseEvent(Ljava/awt/event/MouseEvent;)V+23
j java.awt.Component.processEvent(Ljava/awt/AWTEvent;)V+81
j java.awt.Container.processEvent(Ljava/awt/AWTEvent;)V+18
j java.awt.Component.dispatchEventImpl(Ljava/awt/AWTEvent;)V+570
j java.awt.Container.dispatchEventImpl(Ljava/awt/AWTEvent;)V+42
j java.awt.Component.dispatchEvent(Ljava/awt/AWTEvent;)V+2
j java.awt.LightweightDispatcher.retargetMouseEvent(Ljava/awt/Component;ILjava/awt/event/MouseEvent;)V+320
j java.awt.LightweightDispatcher.processMouseEvent(Ljava/awt/event/MouseEvent;)Z+139
j java.awt.LightweightDispatcher.dispatchEvent(Ljava/awt/AWTEvent;)Z+50
j java.awt.Container.dispatchEventImpl(Ljava/awt/AWTEvent;)V+12
j java.awt.Window.dispatchEventImpl(Ljava/awt/AWTEvent;)V+65
j java.awt.Component.dispatchEvent(Ljava/awt/AWTEvent;)V+2
j java.awt.EventQueue.dispatchEventImpl(Ljava/awt/AWTEvent;Ljava/lang/Object;)V+41
j java.awt.EventQueue.access$000(Ljava/awt/EventQueue;Ljava/awt/AWTEvent;Ljava/lang/Object;)V+3
j java.awt.EventQueue$1.run()Ljava/lang/Void;+12
j java.awt.EventQueue$1.run()Ljava/lang/Object;+1
v ~StubRoutines::call_stub
j java.security.AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/ AccessControlContext;)Ljava/lang/Object;+0
j java.security.AccessControlContext$1.doIntersectionPrivilege(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/security/AccessControlContext;)Ljava/lang/Object;+28
j java.security.AccessControlContext$1.doIntersectionPrivilege(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;+6
j java.awt.EventQueue$2.run()Ljava/lang/Void;+11
j java.awt.EventQueue$2.run()Ljava/lang/Object;+1
v ~StubRoutines::call_stub
j java.security.AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;+0
j java.security.AccessControlContext$1.doIntersectionPrivilege(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/security/AccessControlContext;)Ljava/lang/Object;+28
j java.awt.EventQueue.dispatchEvent(Ljava/awt/AWTEvent;)V+73
j java.awt.EventDispatchThread.pumpOneEventForFilters(I)Z+204
j java.awt.EventDispatchThread.pumpEventsForFilter(ILjava/awt/Conditional;Ljava/awt/EventFilter;)V+30
j java.awt.EventDispatchThread.pumpEventsForHierarchy(ILjava/awt/Conditional;Ljava/awt/Component;)V+11
j java.awt.EventDispatchThread.pumpEvents(ILjava/awt/Conditional;)V+4
j java.awt.EventDispatchThread.pumpEvents(Ljava/awt/Conditional;)V+3
j java.awt.EventDispatchThread.run()V+9
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x0312dc00 JavaThread "TimerQueue" daemon [_thread_blocked, id=3508, stack(0x03540000,0x03590000)]
0x002a6400 JavaThread "DestroyJavaVM" [_thread_blocked, id=3588, stack(0x008c0000,0x00910000)]
0x0308f400 JavaThread "D3D Screen Updater" daemon [_thread_blocked, id=3808, stack(0x03370000,0x033c0000)]
=>0x03054400 JavaThread "AWT-EventQueue-0" [_thread_in_native, id=3732, stack(0x03250000,0x032a0000)]
0x02b8f800 JavaThread "AWT-Windows" daemon [_thread_in_native, id=380, stack(0x02f90000,0x02fe0000)]
0x02b8e400 JavaThread "AWT-Shutdown" [_thread_blocked, id=3368, stack(0x02f40000,0x02f90000)]
0x02b8cc00 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=972, stack(0x02ef0000,0x02f40000)]
0x02b48800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=1524, stack(0x02dc0000,0x02e10000)]
0x02b43400 JavaThread "C1 CompilerThread0" daemon [_thread_blocked, id=3272, stack(0x02d70000,0x02dc0000)]
0x02b41000 JavaThread "Attach Listener" daemon [_thread_blocked, id=1364, stack(0x02d20000,0x02d70000)]
0x02b3f800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=2804, stack(0x02cd0000,0x02d20000)]
0x02b38400 JavaThread "Finalizer" daemon [_thread_blocked, id=3164, stack(0x02c80000,0x02cd0000)]
0x02b36c00 JavaThread "Reference Handler" daemon [_thread_blocked, id=1656, stack(0x02c30000,0x02c80000)]
Other Threads:
0x02afa000 VMThread [stack: 0x02be0000,0x02c30000] [id=1988]
0x02b4b400 WatcherThread [stack: 0x02e10000,0x02e60000] [id=956]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 4928K, used 2084K [0x22970000, 0x22ec0000, 0x27ec0000)
eden space 4416K, 47% used [0x22970000, 0x22b791d8, 0x22dc0000)
from space 512K, 0% used [0x22dc0000, 0x22dc0000, 0x22e40000)
to space 512K, 0% used [0x22e40000, 0x22e40000, 0x22ec0000)
tenured generation total 10944K, used 0K [0x27ec0000, 0x28970000, 0x32970000)
the space 10944K, 0% used [0x27ec0000, 0x27ec0000, 0x27ec0200, 0x28970000)
compacting perm gen total 12288K, used 764K [0x32970000, 0x33570000, 0x36970000)
the space 12288K, 6% used [0x32970000, 0x32a2f0f0, 0x32a2f200, 0x33570000)
ro space 10240K, 51% used [0x36970000, 0x36e9e318, 0x36e9e400, 0x37370000)
rw space 12288K, 55% used [0x37370000, 0x37a0a088, 0x37a0a200, 0x37f70000)
Code Cache [0x00910000, 0x009b0000, 0x02910000)
total_blobs=316 nmethods=92 adapters=160 free_code_cache=32927040 largest_free_block=0
Dynamic libraries:
0x00400000 - 0x00425000 C:\WINDOWS\system32\java.exe
0x7c900000 - 0x7c9b0000 C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c8f4000 C:\WINDOWS\system32\kernel32.dll
0x77dd0000 - 0x77e6b000 C:\WINDOWS\system32\ADVAPI32.dll
0x77e70000 - 0x77f01000 C:\WINDOWS\system32\RPCRT4.dll
0x7c340000 - 0x7c396000 C:\Program Files\Java\jre6\bin\msvcr71.dll
0x6d7f0000 - 0x6da9f000 C:\Program Files\Java\jre6\bin\client\jvm.dll
0x77d40000 - 0x77dd0000 C:\WINDOWS\system32\USER32.dll
0x77f10000 - 0x77f56000 C:\WINDOWS\system32\GDI32.dll
0x76b40000 - 0x76b6d000 C:\WINDOWS\system32\WINMM.dll
0x6d7a0000 - 0x6d7ac000 C:\Program Files\Java\jre6\bin\verify.dll
0x6d320000 - 0x6d33f000 C:\Program Files\Java\jre6\bin\java.dll
0x6d7e0000 - 0x6d7ef000 C:\Program Files\Java\jre6\bin\zip.dll
0x6d000000 - 0x6d14c000 C:\Program Files\Java\jre6\bin\awt.dll
0x73000000 - 0x73026000 C:\WINDOWS\system32\WINSPOOL.DRV
0x77c10000 - 0x77c68000 C:\WINDOWS\system32\msvcrt.dll
0x76390000 - 0x763ad000 C:\WINDOWS\system32\IMM32.dll
0x774e0000 - 0x7761c000 C:\WINDOWS\system32\ole32.dll
0x773d0000 - 0x774d2000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common- Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\COMCTL32.dll
0x77f60000 - 0x77fd6000 C:\WINDOWS\system32\SHLWAPI.dll
0x5ad70000 - 0x5ada8000 C:\WINDOWS\system32\uxtheme.dll
0x6d230000 - 0x6d27f000 C:\Program Files\Java\jre6\bin\fontmanager.dll
0x74720000 - 0x7476b000 C:\WINDOWS\system32\MSCTF.dll
0x4fdd0000 - 0x4ff76000 C:\WINDOWS\system32\d3d9.dll
0x03020000 - 0x03026000 C:\WINDOWS\system32\d3d8thk.dll
0x77c00000 - 0x77c08000 C:\WINDOWS\system32\VERSION.dll
0x7c9c0000 - 0x7d1d4000 C:\WINDOWS\system32\shell32.dll
0x6d600000 - 0x6d613000 C:\Program Files\Java\jre6\bin\net.dll
0x71ab0000 - 0x71ac7000 C:\WINDOWS\system32\WS2_32.dll
0x71aa0000 - 0x71aa8000 C:\WINDOWS\system32\WS2HELP.dll
0x6d620000 - 0x6d629000 C:\Program Files\Java\jre6\bin\nio.dll
0x77120000 - 0x771ac000 C:\WINDOWS\system32\OLEAUT32.DLL
0x6d360000 - 0x6d36d000 C:\Program Files\Java\jre6\bin\JdbcOdbc.dll
0x74320000 - 0x7435d000 C:\WINDOWS\system32\ODBC32.dll
0x763b0000 - 0x763f9000 C:\WINDOWS\system32\comdlg32.dll
0x20000000 - 0x20017000 C:\WINDOWS\system32\odbcint.dll
0x032e0000 - 0x032e5000 C:\WINDOWS\system32\msorc32r.dll
0x10000000 - 0x10061000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oci.dll
0x76bf0000 - 0x76bfb000 C:\WINDOWS\system32\PSAPI.DLL
0x61c20000 - 0x61e73000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\ORACLIENT10.DLL
0x60870000 - 0x60956000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oracore10.dll
0x60a80000 - 0x60b46000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oranls10.dll
0x63690000 - 0x636a8000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oraunls10.dll
0x60eb0000 - 0x60eb7000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\orauts.dll
0x636b0000 - 0x636b6000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oravsn10.dll
0x60fa0000 - 0x61092000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oracommon10.dll
0x60300000 - 0x60858000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\orageneric10.dll
0x63430000 - 0x63457000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\orasnls10.dll
0x035a0000 - 0x0372c000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oraxml10.dll
0x03730000 - 0x03741000 C:\WINDOWS\system32\MSVCIRT.dll
0x60960000 - 0x60a6d000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oran10.dll
0x62740000 - 0x6277d000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oranl10.dll
0x62790000 - 0x627a7000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oranldap10.dll
0x627f0000 - 0x628f9000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\orannzsbb10.dll
0x62530000 - 0x62583000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oraldapclnt10.dll
0x62670000 - 0x6268b000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\orancrypt10.dll
0x71ad0000 - 0x71ad9000 C:\WINDOWS\system32\WSOCK32.dll
0x62920000 - 0x6296c000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oranro10.dll
0x626b0000 - 0x626b7000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oranhost10.dll
0x62660000 - 0x62666000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\orancds10.dll
0x629c0000 - 0x629c8000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\orantns10.dll
0x60b50000 - 0x60ea9000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\orapls10.dll
0x63420000 - 0x63429000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oraslax10.dll
0x63080000 - 0x63284000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oraplp10.dll
0x61ed0000 - 0x61f5b000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\orahasgen10.dll
0x62ab0000 - 0x62b1a000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oraocr10.dll
0x62b20000 - 0x62b60000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oraocrb10.dll
0x5b860000 - 0x5b8b4000 C:\WINDOWS\system32\NETAPI32.dll
0x62980000 - 0x62990000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\orantcp10.dll
0x63520000 - 0x635ba000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\orasql10.dll
0x5fe80000 - 0x5fe9b000 C:\WINDOWS\system32\odbccp32.dll
0x77fe0000 - 0x77ff1000 C:\WINDOWS\system32\Secur32.dll
0x62650000 - 0x62659000 C:\oraclexe\app\oracle\product\10.2.0\server\bin\oranbeq10.dll
0x71f80000 - 0x71f84000 C:\WINDOWS\system32\security.dll
0x77c70000 - 0x77c93000 C:\WINDOWS\system32\msv1_0.dll
0x76d60000 - 0x76d79000 C:\WINDOWS\system32\iphlpapi.dll
VM Arguments:
java_command: AddLeave
Launcher Type: SUN_STANDARD
Environment Variables:
CLASSPATH=.
PATH=C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WIN DOWS\System32\Wbem;C:\Program Files\Java\jdk1.6.0\bin;C:\Program Files\Common Files\Nero\Lib\
USERNAME=sunanda
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 13, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows XP Build 2600 Service Pack 2
CPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 15 stepping 13, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3
Memory: 4k page, physical 1045684k(346004k free), swap 2517544k(1203440k free)
vm_info: Java HotSpot(TM) Client VM (20.6-b01) for windows-x86 JRE (1.6.0_31-b05), built on Feb 3 2012 18:44:09 by "java_re" with MS VC++ 7.1 (VS2003)
time: Sun Apr 08 15:46:59 2012
elapsed time: 9 seconds
"Demo" is the name of the database which has 4 columns namely empid,Fname,Lname,designation. The working of the program is that when I enter the employee ID it retrieves the remaining data from the database. As I have not added the department Id column I am not getting that from the database.
I usually see these errors when something went wrong in the JNI (Java Native Interface) code, i.e. here, perhaps the JDBC (Java DataBase Connectivity) driver ODBC32.dll. Are you sure you are using correct version of the JDBC driver for your platform? Especially check you are using 32-bit version on a 32-bit OS (Operating System) and not a 64-bit version (or vice-versa).
The crash happened outside the Java Virtual Machine in native code.
You should be using the Oracle JDBC Driver appropriate for your Oracle database version; these are typically pure Java. The JDBC-ODBC Bridge Driver has significant limitations, including JNI dependency.

Categories

Resources