Examining the xFunc:
void xFunc(sqlite3_context *context, int args, sqlite3_value** value)
{
static jmethodID mth = 0;
if (!mth) {
JNIEnv *env = ((struct UDFData*)sqlite3_user_data(context))-
>env;
mth = (*env)->GetMethodID(env, fclass, "xFunc", "()V");
}
xCall(context, args, value, 0, mth);
}
(gdb) disassemble xFunc
Dump of assembler code for function xFunc:
0x00018a7c <xFunc+0>: push %ebp
0x00018a7d <xFunc+1>: mov %esp,%ebp
0x00018a7f <xFunc+3>: push %esi
0x00018a80 <xFunc+4>: push %ebx
0x00018a81 <xFunc+5>: call 0x18a86 <xFunc+10>
0x00018a86 <xFunc+10>: pop %ebx
0x00018a87 <xFunc+11>: add $0x5fdda,%ebx
0x00018a8d <xFunc+17>: mov 0x8(%ebp),%esi
0x00018a90 <xFunc+20>: cmpl $0x0,0x170(%ebx)
0x00018a97 <xFunc+27>: jne 0x18acc <xFunc+80> -- if (!mth) {
0x00018a99 <xFunc+29>: sub $0xc,%esp
0x00018a9c <xFunc+32>: push %esi
0x00018a9d <xFunc+33>: call 0x18168 <_init+436> --
sqlite3_user_data ?
0x00018aa2 <xFunc+38>: mov (%eax),%edx
0x00018aa4 <xFunc+40>: mov (%edx),%ecx
0x00018aa6 <xFunc+42>: lea 0xffff522a(%ebx),%eax
0x00018aac <xFunc+48>: push %eax
0x00018aad <xFunc+49>: lea 0xffff5309(%ebx),%eax
0x00018ab3 <xFunc+55>: push %eax
0x00018ab4 <xFunc+56>: pushl 0x140(%ebx)
0x00018aba <xFunc+62>: push %edx
0x00018abb <xFunc+63>: call *0x84(%ecx) -- probably here!
(0x3f); GetMethodID ? ECX, according to the dump, is 0x00000000!
0x00018ac1 <xFunc+69>: mov %eax,0x170(%ebx)
0x00018ac7 <xFunc+75>: add $0x20,%esp
0x00018aca <xFunc+78>: mov %esi,%esi
0x00018acc <xFunc+80>: sub $0xc,%esp
0x00018acf <xFunc+83>: pushl 0x170(%ebx)
0x00018ad5 <xFunc+89>: push $0x0
0x00018ad7 <xFunc+91>: pushl 0x10(%ebp)
0x00018ada <xFunc+94>: pushl 0xc(%ebp)
0x00018add <xFunc+97>: push %esi
0x00018ade <xFunc+98>: call 0x188ac <_init+2296>
0x00018ae3 <xFunc+103>: lea 0xfffffff8(%ebp),%esp
0x00018ae6 <xFunc+106>: pop %ebx
0x00018ae7 <xFunc+107>: pop %esi
0x00018ae8 <xFunc+108>: leave
0x00018ae9 <xFunc+109>: ret
0x00018aea <xFunc+110>: mov %esi,%esi
End of assembler dump.
Somehow, it seems, the "env" reference is lost in the UDFData.
The problem, as it seems, is that the JNIEnv must not be used in
another thread.
http://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/design.html#wp16696
Is this a bug or a feature?
It latter, then i'd vote for it being docummented in the
org.sqlite.Function javadoc!
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# SIGSEGV (0xb) at pc=0x7316eabb, pid=15629, tid=0x831b800
#
# Java VM: Java HotSpot(TM) Server VM (diablo-1.5.0_07-b01 mixed mode)
# Problematic frame:
# C [libsqlitejdbc.so+0x18abb] xFunc+0x3f
#
--------------- T H R E A D ---------------
Current thread (0x083c3a00): JavaThread
"btpool0-96" [_thread_in_native, id=137476096]
siginfo:si_signo=11, si_errno=0, si_code=12, si_addr=0x00000084
Registers:
EAX=0x731c3b69, EBX=0x731ce860, ECX=0x00000000, EDX=0x082c84c0
ESP=0xbda02810, EBP=0xbda02838, ESI=0xbda02a50, EDI=0x083c3a00
EIP=0x7316eabb, EFLAGS=0x00010296
Top of Stack: (sp=0xbda02810)
0xbda02810: 082c84c0 08056130 731c3b69 731c3a8a
0xbda02820: bda02a50 00000000 0000000c 7316ea86
0xbda02830: 08236398 6eb951f8 bda02b78 731b3423
0xbda02840: bda02a50 00000003 082384c0 08237100
0xbda02850: 08236000 08237000 08054100 731b07c7
0xbda02860: 00000014 00000000 bda02878 480ab345
0xbda02870: 00000000 00000001 480ad7a4 00000001
0xbda02880: 0831b800 480ad7a4 bda028c8 480a0c16
Instructions: (pc=0x7316eabb)
0x7316eaab: ff 50 8d 83 09 53 ff ff 50 ff b3 40 01 00 00 52
0x7316eabb: ff 91 84 00 00 00 89 83 70 01 00 00 83 c4 20 89
Stack: [0xbd9c4000,0xbda04000), sp=0xbda02810, free space=250k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code,
C=native code)
C [libsqlitejdbc.so+0x18abb] xFunc+0x3f
C [libsqlitejdbc.so+0x5d423] sqlite3VdbeExec+0x10e3
C [libsqlitejdbc.so+0x62c41] sqlite3_result_value+0x215
C [libsqlitejdbc.so+0x62dee] sqlite3_step+0x1e
C [libsqlitejdbc.so+0x1908f] Java_org_sqlite_NativeDB_step+0x27
j org.sqlite.NativeDB.step(J)I+0
j org.sqlite.DB.step(Lorg/sqlite/RS;)I+5
j org.sqlite.DB.execute(Lorg/sqlite/RS;[Ljava/lang/Object;)Z+99
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"SQLiteJDBC" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlitejdbc?hl=en
-~----------~----~----~----~------~----~------~--~---