Skip to main content

CVM hangs at CVMjniInvokeNative() on Montavista/Mips platform

39 replies [Last post]
sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi..
I am using phoneme advance MR1. I modified the makefile to generate cvm+libcvm.so as output. In cvm executable, it contains java_md.c and ansi_java_md.c. The others are built into libcvm.so. I got a strange problem is when I run cvm+libcvm.so on Montavista/Mips environment, I will get signal 11. But if I build all files into one cvm executable, cvm works fine. After some tracing, I found it will crash at (*env)->CallVoidMethod(env, CVMcbJavaInstance(cb), mb); in CVMprivateClassInit() in Classinitialize.c. But CallVoidMethod() seems to enter an assembly code in invokeNative_mips.S. Can someone help me? Thank you very much.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
cjplummer
Offline
Joined: 2006-10-16
Points: 0

> > > CVM_BUILD_SO=true
> > What happens when you don't use this option?
> >
>
> If CVM_BUILD_SO=false, one cvm executable is
> generated.
> And if I run cvm on target, it will hang at some
> place.
> Then I press "ctrl+c", it shows
> Program received signal SIGINT, Interrupt.
> [Switching to Thread 715919536 (LWP 1118)]
> 0x005aac14 in CVMjniInvokeNative ()
> at
> ../../src/mips/javavm/runtime/invokeNative_mips.S:423
> 423
Another sign that there are problems with CVMjniInvokeNative. Looks like it got stuck in an infinite loop. Although it looks like you are using o32 calling conventions, there must be something else going on here with the calling coventions. CVMjniInvokeNative takes 7 arguments. For o32 this means the last 3 should be on the stack. You might want to check the call site to make sure this is what gcc is actually doing, and then check to make sure CVMjniInvokeNative is finding them all properly.

>
> ./../src/mips/javavm/runtime/invokeNative_mips.S: No
> such file or dire. in
> ../../src/mips/javavm/runtime/invokeNative_mips.S
> Current language: auto; currently asm
>
> And the backtrace is corrupted. So I can't call
> CVMdumpStack.

You can use "call CVMgetEE()) to get the ee for the current thread:

(gdb) call CVMgetEE()
$4 = (CVMExecEnv *) 0x8444b60
(gdb) call CVMdumpStack(&$4->interpreterStack,0,0,0)
Java Frame java.lang.Class.runStaticInitializers()V(Class.java:1571)
Transition Frame java.lang.Class.runStaticInitializers()V(Transition Method)
Free List Frame (JNI Local Frame)

> One more thing is the
> Java_java_lang_Class_checkInitializingFlag() returns
> CVM_FALSE. clinitEE is NULL.

This is correct.

Chris

sschang123
Offline
Joined: 2007-07-05
Points: 0

> > Hi, Chris:
> > I've tried to use the latest codes in the trunk.
> > And my build flags are
> >
> > CVM_JIT = false
> > #CVM_JIT_USE_FP_HARDWARE ?= true
> > TOP_DIR=$(shell pwd)
> Leave this option off. It should not be set on the
> command line.
>
> > J2ME_CLASSLIB=cdc
> > JDK_HOME=/opt/j2sdk1.4.2_12
> > TOOLS_DIR=$(TOP_DIR)/../../tools
> > CVM_DEBUG = true
> > CVM_TOOLS_DIR = /opt
> Also leave this option off. It probably is not doing
> anything.
>
> > CVM_TARGET_TOOLS_DIR =
> >
> $(CVM_TOOLS_DIR)/montavista/pro/devkit/mips/mips2_fp_b
>
> > e/bin
> > CVM_TARGET_TOOLS_PREFIX =
> > $(CVM_TARGET_TOOLS_DIR)/mips2_fp_be-
> Only one of the above is needed.
>
> > CVM_BUILD_SO=true
> What happens when you don't use this option?
>

If CVM_BUILD_SO=false, one cvm executable is generated.
And if I run cvm on target, it will hang at some place.
Then I press "ctrl+c", it shows
Program received signal SIGINT, Interrupt.
[Switching to Thread 715919536 (LWP 1118)]
0x005aac14 in CVMjniInvokeNative ()
at ../../src/mips/javavm/runtime/invokeNative_mips.S:423
423 ../../src/mips/javavm/runtime/invokeNative_mips.S: No such file or dire. in ../../src/mips/javavm/runtime/invokeNative_mips.S
Current language: auto; currently asm

And the backtrace is corrupted. So I can't call CVMdumpStack.
One more thing is the Java_java_lang_Class_checkInitializingFlag() returns CVM_FALSE. clinitEE is NULL.

cjplummer
Offline
Joined: 2006-10-16
Points: 0

The -1 must mean CVMjniIvokeNative is not working, since we know the JNI method is returning 0 (CVM_FALSE). You'll need to single step (si) out of Java_java_lang_Class_checkInitializingFlag and into CVMjniInvokeNative to see how it is handling the result. Note that &returnValue.jni is passed into CVMjniInvokeNative, and filled in after the JNI method returns to CVMjniInvokeNative. You may want to set a breakpoint first in CVMinvokeJNIHelper to get the proper value for &returnValue.jni, make sure it is properly passed to CVMjniInvokeNative, and then make sure it is properly filled in before returning back to CVMinvokeJNIHelper.

BTW, i'm really starting to suspect you are not using o32 calling conventions. The result of the -dM -E compiler run will answer this.

Chris

cjplummer
Offline
Joined: 2006-10-16
Points: 0

> Hi, Chris:
> I think maybe there are some other codes need to be
> fixed also.
> Following message is the result of applying the
> changes.
>
> JNI_CreateJavaVM
> CVM Configuration:
> Java stack chunk size (stackChunkSize): 1024
> Java stack minimum size (stackMinSize): 1024
> Java stack maximum size (stackMaxSize):
> 131072
> C[SS]: Initialized semi-space gen for generational
> GC
> Size of *each* semispace in bytes=1048576
> Limits of generation = [0x2add7200,0x2afd7200)
> First semispace =
> [0x2add7200,0x2aed7200)
> Second semispace =
> [0x2aed7200,0x2afd7200)
> C[MC]: Initialized mark-compact gen for generational
> GC
> Size of the space in bytes=4194304
> Limits of generation = [0x2afd7200,0x2b3d7200)
> GC[generational]: Auxiliary data structures
> heapBaseMemoryArea=[0x2add7008,0x2b3d7208)
> cardTable=[0x10107350,0x1010a350)
> objectHeaderTable=[0x1010a358,0x1010d358)
> summaryTable=[0x1010d360,0x10119360)
> [b]ee=0x100bc338 clinitEE=0x0 eeRawX=0x0
> cb=0x1006e1dc java.lang.Class[/b]
>
> Here is the build flag I used.
> J2ME_CLASSLIB=basis
> AWT_IMPLEMENTATION=directfb
> OPT_PKGS=security
> CVM_DEBUG = true
> CVM_JIT=false
> CVM_JIT_USE_FP_HARDWARE=false
> CVM_SYMBOLS=true
>
> Thanks.

Your output above says that clinitEE=0x0. Java_java_lang_Class_checkInitializingFlag should return CVM_FALSE in this case. This in turns mean that when called from Class.runStaticInitializers, the wait(0) should not end up being done. It looks like CVMjniinvokeMethod is not properly handling the result of Java_java_lang_Class_checkInitializingFlag. It turns out this is actually the first call to a JNI method.

Start by debugging in CVMinvokeJNIHelper in interpreter.c. Set a breakpoint at the switch(returnCode) statement near the end. When you hit it, print out the value of returnValue. It should be 0. Also check returnCode, which should be 1. (You can also do this with a printf rather than use GDB). If either of these are not correct, then there is probably a problem with the CVMjniinvokeMethod assembler code. Possibly you are not using standard o32 calling conventions.

BTW, I'm assuming this test case was without applying any changes except for the debug printf, and you are not building as a shared library.

Chris

sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi, Chris:
Here is the result of two cases.
case 1: build all object files into one cvm

CVM Configuration:
Java stack chunk size (stackChunkSize): 1024
Java stack minimum size (stackMinSize): 1024
Java stack maximum size (stackMaxSize): 131072
GC[SS]: Initialized semi-space gen for generational GC
Size of *each* semispace in bytes=1048576
Limits of generation = [0x2add7200,0x2afd7200)
First semispace = [0x2add7200,0x2aed7200)
Second semispace = [0x2aed7200,0x2afd7200)
GC[MC]: Initialized mark-compact gen for generational GC
Size of the space in bytes=4194304
Limits of generation = [0x2afd7200,0x2b3d7200)
GC[generational]: Auxiliary data structures
heapBaseMemoryArea=[0x2add7008,0x2b3d7208)
cardTable=[0x10107358,0x1010a358)
objectHeaderTable=[0x1010a360,0x1010d360)
summaryTable=[0x1010d368,0x10119368)
ee=0x100bc338 clinitEE=0x0 eeRawX=0x0 cb=0x1006e1dc java.lang.Class
returnCode:1
returnValue:-1

Case 2: build object files into libcvm.so

CVM Configuration:
Java stack chunk size (stackChunkSize): 1024
Java stack minimum size (stackMinSize): 1024
Java stack maximum size (stackMaxSize): 131072
GC[SS]: Initialized semi-space gen for generational GC
Size of *each* semispace in bytes=1048576
Limits of generation = [0x2b2f7200,0x2b4f7200)
First semispace = [0x2b2f7200,0x2b3f7200)
Second semispace = [0x2b3f7200,0x2b4f7200)
GC[MC]: Initialized mark-compact gen for generational GC
Size of the space in bytes=4194304
Limits of generation = [0x2b4f7200,0x2b8f7200)
GC[generational]: Auxiliary data structures
heapBaseMemoryArea=[0x2b2f7008,0x2b8f7208)
cardTable=[0x10007b50,0x1000ab50)
objectHeaderTable=[0x1000ab58,0x1000db58)
summaryTable=[0x1000db60,0x10019b60)
ee=0x2b2630b8 clinitEE=0x0 eeRawX=0x0 cb=0x2b214a74 java.lang.Class
returnCode:1
returnValue:-1

The returnValue is not 0. I got -1.
Does this means "CVMjniinvokeMethod is not properly handling the result of Java_java_lang_Class_checkInitializingFlag"?
If so, how can I verify this? Thank you.

cjplummer
Offline
Joined: 2006-10-16
Points: 0

Switch to a frame with an ee argument, like frame #2, using the frame command. Then use the following commands:

call CVMdumpStack(&ee->interpreterStack,0,0,0)
call CVMdumpAllThreads()

Also, what are you running when this happens? Is this during Test? If so, what output do you see just before the hang?

One last question. Are you running on an multi-core machine?

Chris

sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi, Chris:
Thank you. There are two CPUs on the target board. Here is the CPU information.
• High Performance Vr5500 MIPS MPU(Front-end)
– 64bit 2way Superscalar MIPS MPU
– 374MIPS@187MHz(Dhrystone)
– 32KB I-Cache + 32KB D-Cache
• MIPS MPU for Real-time Control(Back-end for hardware decoder)
– MIPS32 CPU
– 224MIPS@187MHz(Dhrystone)
– 8KB I-Cache + 8KB D-Cache
The kernel is "2.6.10 mips2_fp_be" and gcc version is "3.4.3(Montavista 3.4.3-25.0.30.0501131)".

The command I execute CVM is "./bin/cvm -cp testclasses.zip HelloWorld".
After one minute passing, I can just only see the following messages.

CVM Configuration:
Java stack chunk size (stackChunkSize): 1024
Java stack minimum size (stackMinSize): 1024
Java stack maximum size (stackMaxSize): 131072
GC[SS]: Initialized semi-space gen for generational GC
Size of *each* semispace in bytes=1048576
Limits of generation = [0x2b2f7200,0x2b4f7200)
First semispace = [0x2b2f7200,0x2b3f7200)
Second semispace = [0x2b3f7200,0x2b4f7200)
GC[MC]: Initialized mark-compact gen for generational GC
Size of the space in bytes=4194304
Limits of generation = [0x2b4f7200,0x2b8f7200)
GC[generational]: Auxiliary data structures
heapBaseMemoryArea=[0x2b2f7008,0x2b8f7208)
cardTable=[0x10007b40,0x1000ab40)
objectHeaderTable=[0x1000ab48,0x1000db48)
summaryTable=[0x1000db50,0x10019b50)

No more messages outputed and it doesn't return to (gdb) prompt.
So I press "ctrl+c" and it shows following messages in gdb.

Program received signal SIGINT, Interrupt.
[Switching to Thread 715920272 (LWP 1031)]
__pthread_cond_wait (cond=0x2b2630b0, mutex=0x2b263094)
at ../nptl/sysdeps/pthread/pthread_cond_wait.c:146
146 ../nptl/sysdeps/pthread/pthread_cond_wait.c: No such file or directory.
in ../nptl/sysdeps/pthread/pthread_cond_wait.c

Then I call bt in gdb. I will get the stacktrace as previous post.
Here is the result that I call frame 2 and dump stack and threads.

[b](gdb) frame 2
#2 0x2aed9630 in CVMreentrantMutexWait (ee=0x2b262fc8, rm=0x10003218,
c=0x10003238, millis=0) at ../../src/share/javavm/runtime/sync.c:152
152 CVMreentrantMutexDoWait(rm, ee, {
(gdb) call CVMdumpStack(&ee->interpreterStack,0,0,0)
JNI Frame java.lang.Object.wait(J)V(Native Method)
Java Frame java.lang.Class.runStaticInitializers()V(Class.java:1568)
Transition Frame java.lang.Class.runStaticInitializers()V(Transition Method)
Free List Frame (JNI Local Frame)
(gdb) call CVMdumpAllThreads()
Thread ee=0x2b262fc8, ID=0
JNI Frame java.lang.Object.wait(J)V(Native Method)
Java Frame java.lang.Class.runStaticInitializers()V(Class.java:1568)
Transition Frame java.lang.Class.runStaticInitializers()V(Transition Method)
Free List Frame (JNI Local Frame)[/b]

Thanks for your quick reply.

cjplummer
Offline
Joined: 2006-10-16
Points: 0

The dual cores are going to be a problem. The CVM mips release is not MP-safe. You'll need to force CVM to run on one CPU. There is some code to do this in src/linux/javavm/runtime/globals_md.c to do this, but it is experimental and currently has a #if 0 around it. You can try including it in the build and see if it works. Make sure it does actually get compiled in, since it also is dependent on __cpu_set_t_defined being defined.

However, having two CPUs is not the cause of the problem you are seeing, since this is early in startup and there is only one thread. For some reason CVM thinks a class is currently having its static initializer run by another thread, but I don't believe this can be the case yet. Apply the following diff, rerun, and send me the output.

Index: src/share/native/java/lang/Class.c
===================================================================
--- src/share/native/java/lang/Class.c (revision 6989)
+++ src/share/native/java/lang/Class.c (working copy)
@@ -218,6 +218,8 @@
CVMExecEnv* ee = CVMjniEnv2ExecEnv(env);
CVMClassBlock* cb = gcSafeRef2Class(ee, cls);
CVMExecEnv* clinitEE = CVMcbGetClinitEE(ee, cb);
+ CVMconsolePrintf("ee=0x%x clinitEE=0x%x eeRawX=0x%x cb=0x%x %C\n",
+ ee, clinitEE, CVMcbClinitEERawX(ee, cb), cb, cb);
#if 0
/* the wince clmips compiler generates bad code for the following */
return (clinitEE != NULL) && ((clinitEE == ee) == me);

BTW, I'm assuming you are running the latest rev of cdc, haven't made any other changes to the source, and are only using standard build flags, like J2ME_CLASSLIB, CVM_DEBUG, and CVM_OPTIMIZED. If this is not the case, I need to know what else you are doing.

thanks,

Chris

sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi, Chris:
I think maybe there are some other codes need to be fixed also.
Following message is the result of applying the changes.

JNI_CreateJavaVM
CVM Configuration:
Java stack chunk size (stackChunkSize): 1024
Java stack minimum size (stackMinSize): 1024
Java stack maximum size (stackMaxSize): 131072
GC[SS]: Initialized semi-space gen for generational GC
Size of *each* semispace in bytes=1048576
Limits of generation = [0x2add7200,0x2afd7200)
First semispace = [0x2add7200,0x2aed7200)
Second semispace = [0x2aed7200,0x2afd7200)
GC[MC]: Initialized mark-compact gen for generational GC
Size of the space in bytes=4194304
Limits of generation = [0x2afd7200,0x2b3d7200)
GC[generational]: Auxiliary data structures
heapBaseMemoryArea=[0x2add7008,0x2b3d7208)
cardTable=[0x10107350,0x1010a350)
objectHeaderTable=[0x1010a358,0x1010d358)
summaryTable=[0x1010d360,0x10119360)
[b]ee=0x100bc338 clinitEE=0x0 eeRawX=0x0 cb=0x1006e1dc java.lang.Class[/b]

Here is the build flag I used.
J2ME_CLASSLIB=basis
AWT_IMPLEMENTATION=directfb
OPT_PKGS=security
CVM_DEBUG = true
CVM_JIT=false
CVM_JIT_USE_FP_HARDWARE=false
CVM_SYMBOLS=true

Thanks.

sschang123
Offline
Joined: 2007-07-05
Points: 0

Sorry. I am using mr1 release.
Maybe I will try to use mr2 later.
Thanks.

sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi, Chris:
I've tried to use the latest codes in the trunk.
And my build flags are

CVM_JIT = false
#CVM_JIT_USE_FP_HARDWARE ?= true
TOP_DIR=$(shell pwd)
J2ME_CLASSLIB=cdc
JDK_HOME=/opt/j2sdk1.4.2_12
TOOLS_DIR=$(TOP_DIR)/../../tools
CVM_DEBUG = true
CVM_TOOLS_DIR = /opt
CVM_TARGET_TOOLS_DIR = $(CVM_TOOLS_DIR)/montavista/pro/devkit/mips/mips2_fp_be/bin
CVM_TARGET_TOOLS_PREFIX = $(CVM_TARGET_TOOLS_DIR)/mips2_fp_be-
CVM_BUILD_SO=true

If I don't apply your fix, the error is the same as previous post.
If I apply your fix, I got following error.

Starting program: /home/cdc_02/bin/cvm_main -cp testclasses.zip HelloWorld[Thread debugging using libthread_db enabled]
[New Thread 715919504 (LWP 1237)]
68 cvm_main.c
70 cvm_main.c
72 cvm_main.c
79 cvm_main.c
104 cvm_main.c
107 cvm_main.c
112 cvm_main.c
CVM Configuration:
Java stack chunk size (stackChunkSize): 1024
Java stack minimum size (stackMinSize): 1024
Java stack maximum size (stackMaxSize): 131072
GC[SS]: Initialized semi-space gen for generational GC
Size of *each* semispace in bytes=1048576
Limits of generation = [0x2b22b000,0x2b42b000)
First semispace = [0x2b22b000,0x2b32b000)
Second semispace = [0x2b32b000,0x2b42b000)
GC[MC]: Initialized mark-compact gen for generational GC
Size of the space in bytes=1048576
Limits of generation = [0x2b42b000,0x2b52b000)
GC[generational]: Sizes
youngGen = min 1048576 start 1048576 max 1048576
oldGen = min 1048576 start 1048576 max 4194304
overall = min 2097152 start 2097152 max 5242880
GC[generational]: Auxiliary data structures
heapBaseMemoryArea=[0x2b22b000,0x2b82b200)
cardTable=[0x2b82b000,0x2b82e000)
objectHeaderTable=[0x2b82e000,0x2b831000)
summaryTable=[0x2b831000,0x2b83d000)

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 715919504 (LWP 1237)]
0x2afd3fdc in CVMgcUnsafeExecuteJavaMethod (ee=0x2b1ac1c0, mb=0x7fff7820,
isStatic=268475492, isVirtual=268475532)
at ../../src/share/javavm/runtime/executejava_standard.c:1844
1844 ARRAY_INTRO(T, -3);

And following is the backtrace in gdb.

(gdb) info registers
zero at v0 v1 a0 a1 a2 a3
R0 00000000 2afd1468 40f99999 40f99999 2b1a82c0 2afe4d80 00000000 7fff7640
t0 t1 t2 t3 t4 t5 t6 t7
R8 10001a0c 2afe4dd4 00000004 00000000 7fff75f4 40000000 e0000000 40000000
s0 s1 s2 s3 s4 s5 s6 s7
R16 00000028 2aaffef8 00401f70 100077e8 10012508 0000006c 10012c08 00000000
t8 t9 k0 k1 gp sp s8 ra
R24 00000999 2afd3fd8 2aff5195 00000000 2b134f40 7fff75a8 7fff75a8 2afe4fdc
sr lo hi bad cause pc
00000000 00004890 00000000 40f9999b 00000008 2afd3fdc
fsr fir
00001004 00000000
(gdb) bt
#0 0x2afd3fdc in CVMgcUnsafeExecuteJavaMethod (ee=0x2b1ac1c0, mb=0x7fff7820,
isStatic=268475492, isVirtual=268475532)
at ../../src/share/javavm/runtime/executejava_standard.c:1844
#1 0x7fff7800 in ?? ()
warning: GDB can't find the start of the function at 0x7fff7800.

GDB is unable to find the start of the function at 0x7fff7800
and thus can't determine the size of that function's stack frame.
This means that GDB may be unable to access that stack frame, or
the frames below it.
This problem is most likely caused by an invalid program counter or
stack pointer.
However, if you think GDB should simply search farther back
from 0x7fff7800 for code which looks like the beginning of a
function, you can increase the range of the search using the `set
heuristic-fence-post' command.
warning: Previous frame inner to this frame (corrupt stack?)

I create a cvm_main.c and it will use dlopen to load libcvm_g.so.
If you need this file, I can send it to you.
Thank you.

cjplummer
Offline
Joined: 2006-10-16
Points: 0

> Hi, Chris:
> I've tried to use the latest codes in the trunk.
> And my build flags are
>
> CVM_JIT = false
> #CVM_JIT_USE_FP_HARDWARE ?= true
> TOP_DIR=$(shell pwd)
Leave this option off. It should not be set on the command line.

> J2ME_CLASSLIB=cdc
> JDK_HOME=/opt/j2sdk1.4.2_12
> TOOLS_DIR=$(TOP_DIR)/../../tools
> CVM_DEBUG = true
> CVM_TOOLS_DIR = /opt
Also leave this option off. It probably is not doing anything.

> CVM_TARGET_TOOLS_DIR =
> $(CVM_TOOLS_DIR)/montavista/pro/devkit/mips/mips2_fp_b
> e/bin
> CVM_TARGET_TOOLS_PREFIX =
> $(CVM_TARGET_TOOLS_DIR)/mips2_fp_be-
Only one of the above is needed.

> CVM_BUILD_SO=true
What happens when you don't use this option?

>
> If I don't apply your fix, the error is the same as
> previous post.
> If I apply your fix, I got following error.
>
> Starting program: /home/cdc_02/bin/cvm_main -cp
> testclasses.zip HelloWorld[Thread debugging using
> libthread_db enabled]
> [New Thread 715919504 (LWP 1237)]
> 68 cvm_main.c
> 70 cvm_main.c
> 72 cvm_main.c
> 79 cvm_main.c
> 104 cvm_main.c
> 107 cvm_main.c
> 112 cvm_main.c
> CVM Configuration:
> Java stack chunk size (stackChunkSize): 1024
> Java stack minimum size (stackMinSize): 1024
> Java stack maximum size (stackMaxSize):
> 131072
> C[SS]: Initialized semi-space gen for generational
> GC
> Size of *each* semispace in bytes=1048576
> Limits of generation = [0x2b22b000,0x2b42b000)
> First semispace =
> [0x2b22b000,0x2b32b000)
> Second semispace =
> [0x2b32b000,0x2b42b000)
> C[MC]: Initialized mark-compact gen for generational
> GC
> Size of the space in bytes=1048576
> Limits of generation = [0x2b42b000,0x2b52b000)
> GC[generational]: Sizes
> youngGen = min 1048576 start 1048576 max
> 1048576
> oldGen = min 1048576 start 1048576 max
> 4194304
> overall = min 2097152 start 2097152 max
> 5242880
> C[generational]: Auxiliary data structures
> heapBaseMemoryArea=[0x2b22b000,0x2b82b200)
> cardTable=[0x2b82b000,0x2b82e000)
> objectHeaderTable=[0x2b82e000,0x2b831000)
> summaryTable=[0x2b831000,0x2b83d000)
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 715919504 (LWP 1237)]
> 0x2afd3fdc in CVMgcUnsafeExecuteJavaMethod
> (ee=0x2b1ac1c0, mb=0x7fff7820,
> isStatic=268475492, isVirtual=268475532)
> at
> ../../src/share/javavm/runtime/executejava_standard.c:
> 1844
> 1844 ARRAY_INTRO(T, -3);
You might want to try running with -Xtrace:1 for bytecode tracing or -Xtrace:2 for method tracing. You can combine both with -Xtrace:3.
>
> And following is the backtrace in gdb.
>
> (gdb) info registers
> zero at v0 v1 a0
> a1 a2 a3
> 0000000 2afd1468 40f99999 40f99999 2b1a82c0 2afe4d80
> 00000000 7fff7640
> t0 t1 t2 t3 t4
> t5 t6 t7
> 10001a0c 2afe4dd4 00000004 00000000 7fff75f4 40000000
> e0000000 40000000
> s0 s1 s2 s3 s4
> s5 s6 s7
> 00000028 2aaffef8 00401f70 100077e8 10012508 0000006c
> 10012c08 00000000
> t8 t9 k0 k1 gp
> sp s8 ra
> 00000999 2afd3fd8 2aff5195 00000000 2b134f40 7fff75a8
> 7fff75a8 2afe4fdc
> sr lo hi bad cause
> pc
> 0000000 00004890 00000000 40f9999b 00000008 2afd3fdc
> fsr fir
> 004 00000000
> (gdb) bt
> #0 0x2afd3fdc in CVMgcUnsafeExecuteJavaMethod
> (ee=0x2b1ac1c0, mb=0x7fff7820,
> isStatic=268475492, isVirtual=268475532)
> at
> ../../src/share/javavm/runtime/executejava_standard.c:
> 1844
> #1 0x7fff7800 in ?? ()
> warning: GDB can't find the start of the function at
> 0x7fff7800.
>
Try "call CVMdumpStack(&ee->interpreterStack,0,0,0)"

Also, have you added the printf in Java_java_lang_Class_checkInitializingFlag?

> I create a cvm_main.c and it will use dlopen to load
> libcvm_g.so.
> If you need this file, I can send it to you.
At the moment I'd rather not go down this path. Besides the legal issues of you sending me source, I probably won't have the time to debug this. Also, I'm guessing this has more to do with your toolchain and platform than it does with building as a dll, so I probably could not reproduce the problem anyway.

> Thank you.

Chris

cjplummer
Offline
Joined: 2006-10-16
Points: 0

Can you compile a small test program (or empty compilation unit) with the -dM -E flags, plus any other compiler flags you normally pass in (except -c), and send me the output?

thanks

Chris

sschang123
Offline
Joined: 2007-07-05
Points: 0

I wrote a simple c program.

#include
int main(int argc, const char **argv)
{
printf("Hello World\n");
return 1;
}

And here is my compile option.
/opt/montavista/pro/devkit/mips/mips2_fp_be/bin/mips2_fp_be-gcc -dM -E -g -fno-common -Wall -fno-strict-aliasing -mips2 -g -DCVM_DEBUG -DCVM_INSPECTOR -DCVM_DEBUG_CLASSINFO -DCVM_DEBUG_STACKTRACES -DCVM_DEBUG_DUMPSTACK -DCVM_DEBUG_ASSERTS -DCVM_CLASSLOADING -DCVM_SERIALIZATION -DCVM_REFLECT -DCVM_DYNAMIC_LINKING -DCVM_JIT_REGISTER_LOCALS -DCVM_TIMESTAMPING -DCVM_TRACE -DJ2ME_CLASSLIB=cdc -DTARGET_CPU_FAMILY=mips -DCVM_TRACE_ENABLED -D_GNU_SOURCE -o hello1.o hello.c

Here is the output result in hello1.o.

# 1 "/home/user1/phoneme-advanced-02//"
#define _IO_CURRENTLY_PUTTING 0x800
#define __DBL_MIN_EXP__ (-1021)
#define CVM_CLASSLOADING 1
#define __FLT_MIN__ 1.17549435e-38F
#define _IO_UNITBUF 020000
#define _T_WCHAR_
#define _G_HAVE_LONG_DOUBLE_IO 1
#define __flexarr []
#define __S64_TYPE __quad_t
#define __stub_fchflags
#define __SQUAD_TYPE long long int
#define _BSD_SIZE_T_DEFINED_
#define __CHAR_BIT__ 8
#define CVM_TRACE 1
#define _G_OPEN64 __open64
#define stderr stderr
#define R3000 1
#define __GLIBC_PREREQ(maj,min) ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
#define _XOPEN_SOURCE 600
#define __WCHAR_MAX__ 2147483647
#define __BLKCNT_T_TYPE __SLONGWORD_TYPE
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
#define _IO_flockfile(_fp)
#define _IOFBF 0
#define __USE_BSD 1
#define __FLT_EVAL_METHOD__ 0
#define _IO_USER_LOCK 0x8000
#define _IO_NO_WRITES 8
#define __ASMNAME2(prefix,cname) __STRING (prefix) cname
#define _WINT_T
#define _G_HAVE_ST_BLKSIZE defined (_STATBUF_ST_BLKSIZE)
#define __stub_setlogin
#define _IO_peekc_unlocked(_fp) (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) && __underflow (_fp) == EOF ? EOF : *(unsigned char *) (_fp)->_IO_read_ptr)
#define _G_VTABLE_LABEL_PREFIX "__vt_"
#define _MIPS_ISA _MIPS_ISA_MIPS2
#define _IO_getwc_unlocked(_fp) (_IO_BE ((_fp)->_wide_data->_IO_read_ptr >= (_fp)->_wide_data->_IO_read_end, 0) ? __wuflow (_fp) : (_IO_wint_t) *(_fp)->_wide_data->_IO_read_ptr++)
#define __GID_T_TYPE __U32_TYPE
#define __LANGUAGE_C 1
#define __DBL_MIN_10_EXP__ (-307)
#define __FINITE_MATH_ONLY__ 0
#define _MIPS_TUNE "r6000"
#define _G_HAVE_SYS_WAIT 1
#define __GNUC_PATCHLEVEL__ 3
#define _IO_pid_t _G_pid_t
#define _G_off_t __off_t
#define __size_t
#define _WCHAR_T_DEFINED
#define _ABIO32 1
#define _IO_FLAGS2_MMAP 1
#define _IO_HAVE_SYS_WAIT _G_HAVE_SYS_WAIT
#define __SHRT_MAX__ 32767
#define __LDBL_MAX__ 1.7976931348623157e+308L
#define _PARAMS(protos) __P(protos)
#define _IOS_BIN 128
#define __mbstate_t_defined 1
#define CVM_SERIALIZATION 1
#define __LANGUAGE_C__ 1
#define _G_ssize_t __ssize_t
#define __linux 1
#define _BITS_TYPES_H 1
#define _IO_cleanup_region_end(_Doit)
#define _IO_DONT_CLOSE 0100000
#define __unix 1
#define __UID_T_TYPE __U32_TYPE
#define getc(_fp) _IO_getc (_fp)
#define __SIZE_T
#define __LDBL_MAX_EXP__ 1024
#define _IO_ssize_t _G_ssize_t
#define __linux__ 1
#define _IOS_OUTPUT 2
#define _SIZE_T_DEFINED_
#define __SCHAR_MAX__ 127
#define __USING_NAMESPACE_STD(name)
#define _IO_UNIFIED_JUMPTABLES 1
#define __KERNEL_STRICT_NAMES
#define _IO_stderr ((_IO_FILE*)(&_IO_2_1_stderr_))
#define __NTH(fct) __attribute__ ((__nothrow__)) fct
#define _G_MMAP64 __mmap64
#define _POSIX_SOURCE 1
#define _G_uid_t __uid_t
#define __attribute_used__ __attribute__ ((__used__))
#define _STDIO_USES_IOSTREAM
#define _IO_IN_BACKUP 0x100
#define __USER_LABEL_PREFIX__
#define __GLIBC__ 2
#define __END_DECLS
#define __CONCAT(x,y) x ## y
#define __STDC_HOSTED__ 1
#define _LARGEFILE64_SOURCE 1
#define __LDBL_HAS_INFINITY__ 1
#define __SLONG32_TYPE long int
#define _IO_LINE_BUF 0x200
#define _IOS_NOCREATE 32
#define __mips_fpr 32
#define __stub_getcontext
#define __GNU_LIBRARY__ 6
#define __DBL_DIG__ 15
#define _G_BUFSIZ 8192
#define __FLT_EPSILON__ 1.19209290e-7F
#define _G_HAVE_BOOL 1
#define _IO_EOF_SEEN 0x10
#define TMP_MAX 238328
#define __SSIZE_T_TYPE __SWORD_TYPE
#define __DEV_T_TYPE __UQUAD_TYPE
#define _IO_SKIPWS 01
#define _IO_SCIENTIFIC 04000
#define __LDBL_MIN__ 2.2250738585072014e-308L
#define CVM_TIMESTAMPING 1
#define _IO_SHOWPOS 02000
#define _WCHAR_T_
#define _VA_LIST_DEFINED
#define MIPSEB 1
#define __unix__ 1
#define _G_wchar_t wchar_t
#define _IONBF 2
#define _IO_getc_unlocked(_fp) (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) ? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
#define __STDC_IEC_559__ 1
#define __STDC_ISO_10646__ 200009L
#define _IO_PENDING_OUTPUT_COUNT(_fp) ((_fp)->_IO_write_ptr - (_fp)->_IO_write_base)
#define __DECIMAL_DIG__ 17
#define CVM_JIT_REGISTER_LOCALS 1
#define __gnu_linux__ 1
#define _LARGEFILE_SOURCE 1
#define _IO_LEFT 02
#define __LDBL_HAS_QUIET_NAN__ 1
#define __THROW __attribute__ ((__nothrow__))
#define __GLIBC_HAVE_LONG_LONG 1
#define L_tmpnam 20
#define ___int_wchar_t_h
#define __GNUC__ 3
#define L_ctermid 9
#define __OFF64_T_TYPE __SQUAD_TYPE
#define __USE_SVID 1
#define _R3000 1
#define CVM_REFLECT 1
#define SEEK_CUR 1
#define _G_stat64 stat64
#define __USE_ISOC99 1
#define _G_wint_t wint_t
#define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
#define _IO_uid_t _G_uid_t
#define _GCC_WCHAR_T
#define __DBL_MAX__ 1.7976931348623157e+308
#define __DBL_HAS_INFINITY__ 1
#define __USE_XOPEN 1
#define stdin stdin
#define __USE_XOPEN2K 1
#define __DADDR_T_TYPE __S32_TYPE
#define __END_NAMESPACE_C99
#define __FD_SETSIZE 1024
#define __attribute_format_strfmon__(a,b) __attribute__ ((__format__ (__strfmon__, a, b)))
#define _IO_MAGIC 0xFBAD0000
#define _SIZE_T_DEFINED
#define _WCHAR_T_DEFINED_
#define _G_LSEEK64 __lseek64
#define CVM_TRACE_ENABLED 1
#define __USE_POSIX199506 1
#define _FEATURES_H 1
#define _G_FSTAT64(fd,buf) __fxstat64 (_STAT_VER, fd, buf)
#define _IO_FIXED 010000
#define __stub_fattach
#define _IO_UNBUFFERED 2
#define _IO_pos_t _G_fpos_t
#define _IO_INTERNAL 010
#define __S32_TYPE int
#define __DBL_MAX_EXP__ 1024
#define _BITS_WCHAR_H 1
#define __R3000__ 1
#define _G_VTABLE_LABEL_PREFIX_ID __vt_
#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE
#define __stub_swapcontext
#define _IO_LINKED 0x80
#define _G_HAVE_IO_GETLINE_INFO 1
#define __bounded
#define __USECONDS_T_TYPE __U32_TYPE
#define _IO_DELETE_DONT_CLOSE 0x40
#define __BEGIN_NAMESPACE_STD
#define __OFF_T_TYPE __SLONGWORD_TYPE
#define _T_WCHAR
#define __LONG_LONG_MAX__ 9223372036854775807LL
#define _WCHAR_T
#define _MIPS_ARCH_MIPS2 1
#define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)
#define __U16_TYPE unsigned short int
#define _STDIO_H 1
#define __ptrvalue
#define _G_HAVE_IO_FILE_OPEN 1
#define __GXX_ABI_VERSION 1002
#define __USE_GNU 1
#define __FLT_MIN_EXP__ (-125)
#define __MIPSEB__ 1
#define _G_off64_t __off64_t
#define _MIPSEB 1
#define __DBL_MIN__ 2.2250738585072014e-308
#define _MIPS_ARCH "mips2"
#define _IO_MAGIC_MASK 0xFFFF0000
#define __REDIRECT(name,proto,alias) name proto __asm__ (__ASMNAME (#alias))
#define _IO_off64_t _G_off64_t
#define __DBL_HAS_QUIET_NAN__ 1
#define __USE_UNIX98 1
#define _MIPS_TUNE_R6000 1
#define __MODE_T_TYPE __U32_TYPE
#define __nonnull(params) __attribute__ ((__nonnull__ params))
#define __RLIM64_T_TYPE __UQUAD_TYPE
#define _IOS_ATEND 4
#define _IO_BOOLALPHA 0200000
#define __REGISTER_PREFIX__
#define _IOS_NOREPLACE 64
#define _IO_BE(expr,res) __builtin_expect (expr, res)
#define _IO_TIED_PUT_GET 0x400
#define __attribute_pure__ __attribute__ ((__pure__))
#define __USE_POSIX2 1
#define __SLONGWORD_TYPE long int
#define __NO_INLINE__ 1
#define __R3000 1
#define __FLT_MANT_DIG__ 24
#define __VERSION__ "3.4.3 (MontaVista 3.4.3-25.0.30.0501131 2005-07-23)"
#define _SYS_CDEFS_H 1
#define __INT_WCHAR_T_H
#define _IO_file_flags _flags
#define _G_USING_THUNKS 1
#define _BSD_SOURCE 1
#define __STRING(x) #x
#define __unbounded
#define __INO_T_TYPE __ULONGWORD_TYPE
#define __UNKNOWN_10646_CHAR ((wchar_t) 0xfffd)
#define __GNUC_PREREQ(maj,min) ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#define _SYS_SIZE_T_H
#define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)
#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
#define __SIZE_T__
#define __stub_gtty
#define __NLINK_T_TYPE __UWORD_TYPE
#define _IO_SHOWPOINT 0400
#define __stub_sstk
#define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
#define __stub_makecontext
#define __STDC_IEC_559_COMPLEX__ 1
#define _G_HAVE_MMAP 1
#define _IO_OCT 040
#define _G_pid_t __pid_t
#define _IO_putwc_unlocked(_wch,_fp) (_IO_BE ((_fp)->_wide_data->_IO_write_ptr >= (_fp)->_wide_data->_IO_write_end, 0) ? __woverflow (_fp, _wch) : (_IO_wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch)))
#define __stub_setcontext
#define _BITS_TYPESIZES_H 1
#define __SWBLK_T_TYPE __SLONGWORD_TYPE
#define unix 1
#define _BSD_SIZE_T_
#define __SIZE_TYPE__ unsigned int
#define __ULONGWORD_TYPE unsigned long int
#define _SIZE_T_DECLARED
#define _IO_SHOWBASE 0200
#define __ELF__ 1
#define __ID_T_TYPE __U32_TYPE
#define __TIME_T_TYPE __SLONGWORD_TYPE
#define _IO_funlockfile(_fp)
#define __stub_lutimes
#define __FLT_RADIX__ 2
#define __LDBL_EPSILON__ 2.2204460492503131e-16L
#define CVM_DEBUG_ASSERTS 1
#define _G_IO_IO_FILE_VERSION 0x20001
#define __long_double_t long double
#define _IO_IS_FILEBUF 0x2000
#define __WCHAR_MAX (2147483647)
#define _G_ARGS(ARGLIST) ARGLIST
#define SEEK_SET 0
#define _IO_FLAGS2_NOTCANCEL 2
#define _XOPEN_SOURCE_EXTENDED 1
#define __restrict_arr __restrict
#define __USE_MISC 1
#define __UWORD_TYPE unsigned int
#define _SIZE_T_
#define _IO_iconv_t _G_iconv_t
#define _IO_USER_BUF 1
#define _WCHAR_T_H
#define __stub_revoke
#define _MIPS_SZPTR 32
#define _IO_off_t _G_off_t
#define __WCHAR_MIN (-2147483647 - 1)
#define __U64_TYPE __u_quad_t
#define __FLT_HAS_QUIET_NAN__ 1
#define _IO_STDIO_H
#define __FLT_MAX_10_EXP__ 38
#define __LONG_MAX__ 2147483647L
#define __WCHAR_T__
#define __FLT_HAS_INFINITY__ 1
#define NULL ((void *)0)
#define __USING_NAMESPACE_C99(name)
#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE
#define _IO_size_t _G_size_t
#define __stub_lchmod
#define _IO_IS_APPENDING 0x1000
#define CVM_DYNAMIC_LINKING 1
#define _mips 1
#define __PMT(args) args
#define _OLD_STDIO_MAGIC 0xFABC0000
#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
#define linux 1
#define _IOS_APPEND 8
#define ____FILE_defined 1
#define _IOLBF 1
#define _MIPS_SZINT 32
#define _IO_UPPERCASE 01000
#define __KEY_T_TYPE __S32_TYPE
#define __WORDSIZE _MIPS_SZPTR
#define __BEGIN_DECLS
#define __LDBL_MANT_DIG__ 53
#define CVM_DEBUG_CLASSINFO 1
#define _G_NEED_STDARG_H 1
#define __USE_ANSI 1
#define _IO_BAD_SEEN 0x4000
#define __MIPSEB 1
#define __GNUC_VA_LIST
#define __RLIM_T_TYPE __ULONGWORD_TYPE
#define FILENAME_MAX 4096
#define L_cuserid 9
#define __WCHAR_TYPE__ int
#define __CLOCKID_T_TYPE __S32_TYPE
#define _IOS_TRUNC 16
#define __HAVE_COLUMN
#define __stub_fdetach
#define __pic__ 1
#define __stub_chflags
#define putc(_ch,_fp) _IO_putc (_ch, _fp)
#define __UQUAD_TYPE unsigned long long int
#define __USE_POSIX 1
#define BUFSIZ _IO_BUFSIZ
#define __FLT_DIG__ 6
#define __FSID_T_TYPE struct { int __val[2]; }
#define _WCHAR_T_DECLARED
#define J2ME_CLASSLIB cdc
#define _IO_putc_unlocked(_ch,_fp) (_IO_BE ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end, 0) ? __overflow (_fp, (unsigned char) (_ch)) : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
#define CVM_DEBUG_DUMPSTACK 1
#define __INT_MAX__ 2147483647
#define mips 1
#define __S16_TYPE short int
#define CVM_DEBUG_STACKTRACES 1
#define _G_HAVE_ATEXIT 1
#define _T_SIZE_
#define _G_va_list __gnuc_va_list
#define _IOS_INPUT 1
#define __FLT_MAX_EXP__ 128
#define _GCONV_H 1
#define _MIPS_SIM _ABIO32
#define __ptr_t void *
#define __DBL_MANT_DIG__ 53
#define ___int_size_t_h
#define __TIMER_T_TYPE __S32_TYPE
#define __GLIBC_MINOR__ 3
#define __mips__ 1
#define __WINT_TYPE__ unsigned int
#define __LDBL_MIN_EXP__ (-1021)
#define _IO_va_list __gnuc_va_list
#define _MIPS_FPSET 16
#define stdout stdout
#define EOF (-1)
#define __USE_POSIX199309 1
#define __BLKCNT64_T_TYPE __SQUAD_TYPE
#define __LDBL_MAX_10_EXP__ 308
#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE
#define __DBL_EPSILON__ 2.2204460492503131e-16
#define _SIZET_
#define _SVID_SOURCE 1
#define _G_HAVE_SYS_CDEFS 1
#define __stub_stty
#define __wchar_t__
#define SEEK_END 2
#define _ISOC99_SOURCE 1
#define __REDIRECT_NTH(name,proto,alias) name proto __asm__ (__ASMNAME (#alias)) __THROW
#define _IO_RIGHT 04
#define __END_NAMESPACE_STD
#define TARGET_CPU_FAMILY mips
#define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE
#define __PID_T_TYPE __S32_TYPE
#define P_tmpdir "/tmp"
#define _IO_stdin ((_IO_FILE*)(&_IO_2_1_stdin_))
#define _G_size_t size_t
#define _IO_cleanup_region_start(_fct,_fp)
#define _IO_NO_READS 4
#define _IO_DEC 020
#define _SIZE_T
#define _IO_ERR_SEEN 0x20
#define __ULONG32_TYPE unsigned long int
#define _G_config_h 1
#define FOPEN_MAX 16
#define _IO_STDIO 040000
#define _GCC_SIZE_T
#define __INO64_T_TYPE __UQUAD_TYPE
#define __size_t__
#define _IO_BUFSIZ _G_BUFSIZ
#define __FLT_DENORM_MIN__ 1.40129846e-45F
#define __BEGIN_NAMESPACE_C99
#define __PIC__ 1
#define _IO_fpos_t _G_fpos_t
#define __FLT_MAX__ 3.40282347e+38F
#define __USE_LARGEFILE 1
#define LANGUAGE_C 1
#define __FLT_MIN_10_EXP__ (-37)
#define CVM_DEBUG 1
#define _POSIX_C_SOURCE 199506L
#define __SWORD_TYPE int
#define _G_HAVE_PRINTF_FP 1
#define _LANGUAGE_C 1
#define _T_SIZE
#define _IO_stdout ((_IO_FILE*)(&_IO_2_1_stdout_))
#define __GNUC_MINOR__ 4
#define CVM_INSPECTOR 1
#define __DBL_MAX_10_EXP__ 308
#define __FILE_defined 1
#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
#define __USE_XOPEN_EXTENDED 1
#define __mips_hard_float 1
#define __attribute_malloc__ __attribute__ ((__malloc__))
#define __PTRDIFF_TYPE__ int
#define __mips 2
#define __attribute_noinline__ __attribute__ ((__noinline__))
#define _IO_HEX 0100
#define __CLOCK_T_TYPE __SLONGWORD_TYPE
#define _IO_fpos64_t _G_fpos64_t
#define _MIPS_SZLONG 32
#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
#define __LDBL_MIN_10_EXP__ (-307)
#define __attribute_deprecated__ __attribute__ ((__deprecated__))
#define _IO_wint_t _G_wint_t
#define __LDBL_DIG__ 15
#define _G_NAMES_HAVE_UNDERSCORE 0
#define _IO_peekc(_fp) _IO_peekc_unlocked (_fp)
#define _IO_ftrylockfile(_fp)
#define _GNU_SOURCE 1
#define __P(args) args
#define __USE_LARGEFILE64 1
#define __WCHAR_T
#define __U32_TYPE unsigned int
#define _G_VTABLE_LABEL_HAS_LENGTH 1

Thank you.

cjplummer
Offline
Joined: 2006-10-16
Points: 0

Hmm. Looks like you are using o32 calling conventions. I guess we'll need to see what you find out when stepping through CVMjniInvokeNative.

Chris

sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi , Chris:
It's very hard to show the gdb trace.
So I list part of the procedure.
I start at "gdb ./bin/cvm" and then call "run -cp testclasses.zip HelloWorld" in gdb.
I set up break point in CVNjniInvokeNative and CVMinvokeJNIHelper.
Following is part of the log captured from gdb.

(gdb) n
347 jalr FuncPtr
(gdb) p /x $t9
$2 = 0x2afa1c1c
(gdb) x 0x2afa1c1c
0x2afa1c1c : 0x3c1c002c
(gdb) n
350 lw gp, __gp(fp) /* we restore the gp from the stack */
(gdb) n
352 LA(SWITCHBASE, $ret_jumps)
(gdb) n
354 lw a3, stk3 /* pointer to result buffer */
(gdb) info registers
zero at v0 v1 a0 a1 a2 [b]a3[/b]
R0 00000000 2aff9a28 00000000 00000000 00001000 10001a54 00000000 [b]2b1f7944[/b]
t0 t1 t2 t3 t4 t5 t6 t7
R8 10001a5c 2b00d8e4 00000004 00000000 7fff75bc 40000000 1000023c 40000000
s0 s1 s2 s3 s4 s5 s6 s7
R16 0000000a 2aaffef8 00401d80 100077e8 10012808 0000006c 10012c08 00000000
t8 t9 k0 k1 gp sp s8 ra
R24 00000b2b 2af90338 2b01cf95 00000000 2b266500 7fff75b0 7fff75d0 2b00d844
sr lo hi bad cause pc
00000000 00004a90 00000000 2b004c68 00000024 2b00d850
fsr fir
00000000 00000000
(gdb) p /x $fp
$3 = 0x7fff75e0
(gdb) x 0x7fff75f8
[b]0x7fff75f8: 0x7fff7608 <-- I guess here is the &returnValue.jni, and it moved into $a3[/b]
(gdb) n
361 sll RETTYPE, 2
(gdb) info registers
zero at v0 v1 a0 a1 a2 [b]a3[/b]
R0 00000000 2aff9a28 00000000 00000000 00001000 10001a54 00000000 [b]7fff7608[/b]
t0 t1 t2 t3 t4 t5 t6 t7
R8 10001a5c 2b00d8e4 00000004 00000000 7fff75bc 40000000 1000023c 40000000
s0 s1 s2 s3 s4 s5 s6 s7
R16 0000000a 2aaffef8 00401d80 100077e8 10012808 0000006c 10012c08 00000000
t8 t9 k0 k1 gp sp s8 ra
R24 00000b2b 2af90338 2b01cf95 00000000 2b266500 7fff75b0 7fff75d0 2b00d844
sr lo hi bad cause pc
00000000 00004a90 00000000 2b004c68 00000024 2b00d854
fsr fir
00000000 00000000

Then I keep to track 0x7fff7608.

(gdb) n
362 addu a1, SWITCHBASE, RETTYPE
(gdb) info registers
zero at v0 v1 a0 a1 a2 a3
R0 00000000 2aff9a28 00000000 00000000 00001000 10001a54 00000000 7fff7608
t0 t1 t2 t3 t4 t5 t6 t7
R8 10001a5c 2b00d8e4 00000004 00000000 7fff75bc 40000000 1000023c 40000000
s0 s1 s2 s3 s4 s5 s6 s7
R16 00000028 2aaffef8 00401d80 100077e8 10012808 0000006c 10012c08 00000000
t8 t9 k0 k1 gp sp s8 ra
R24 00000b2b 2af90338 2b01cf95 00000000 2b266500 7fff75b0 7fff75d0 2b00d844
sr lo hi bad cause pc
00000000 00004a90 00000000 2b004c68 00000024 2b00d858
fsr fir
00000000 00000000
(gdb) n
363 lw a1, (a1)
(gdb) info registers
zero at v0 v1 a0 a1 a2 a3
R0 00000000 2aff9a28 00000000 00000000 00001000 2b00d90c 00000000 7fff7608
t0 t1 t2 t3 t4 t5 t6 t7
R8 10001a5c 2b00d8e4 00000004 00000000 7fff75bc 40000000 1000023c 40000000
s0 s1 s2 s3 s4 s5 s6 s7
R16 00000028 2aaffef8 00401d80 100077e8 10012808 0000006c 10012c08 00000000
t8 t9 k0 k1 gp sp s8 ra
R24 00000b2b 2af90338 2b01cf95 00000000 2b266500 7fff75b0 7fff75d0 2b00d844
sr lo hi bad cause pc
00000000 00004a90 00000000 2b004c68 00000024 2b00d85c
fsr fir
00000000 00000000
(gdb) x 0x2b00d90c
0x2b00d90c : 0x2b00d890
(gdb) n
364 move sp, fp
(gdb) info registers
zero at v0 v1 a0 a1 a2 a3
R0 00000000 2aff9a28 00000000 00000000 00001000 2b00d890 00000000 7fff7608
t0 t1 t2 t3 t4 t5 t6 t7
R8 10001a5c 2b00d8e4 00000004 00000000 7fff75bc 40000000 1000023c 40000000
s0 s1 s2 s3 s4 s5 s6 s7
R16 00000028 2aaffef8 00401d80 100077e8 10012808 0000006c 10012c08 00000000
t8 t9 k0 k1 gp sp s8 ra
R24 00000b2b 2af90338 2b01cf95 00000000 2b266500 7fff75b0 7fff75d0 2b00d844
sr lo hi bad cause pc
00000000 00004a90 00000000 2b004c68 00000024 2b00d860
fsr fir
00000000 00000000
(gdb) p /x $fp
$4 = 0x7fff75e0
(gdb) n
365 jr a1
(gdb) info registers
zero at v0 v1 a0 a1 a2 a3
R0 00000000 2aff9a28 00000000 00000000 00001000 2b00d890 00000000 7fff7608
t0 t1 t2 t3 t4 t5 t6 t7
R8 10001a5c 2b00d8e4 00000004 00000000 7fff75bc 40000000 1000023c 40000000
s0 s1 s2 s3 s4 s5 s6 s7
R16 00000028 2aaffef8 00401d80 100077e8 10012808 0000006c 10012c08 00000000
t8 t9 k0 k1 gp sp s8 ra
R24 00000b2b 2af90338 2b01cf95 00000000 2b266500 7fff75d0 7fff75d0 2b00d844
sr lo hi bad cause pc
00000000 00004a90 00000000 2b004c68 00000024 2b00d864
fsr fir
00000000 00000000
(gdb) p /x $sp
$5 = 0x7fff75d0
(gdb) p /x $fp
$6 = 0x7fff75e0
(gdb) x 0x2b00d890
0x2b00d890 : 0xace20000
(gdb) n
382 sw v0, (a3)
(gdb) x 0x7fff75f8
0x7fff75f8: 0x7fff7608
(gdb) x 0x7fff7608
0x7fff7608: 0x2b266500
(gdb) n
383 li v0, 1 /* 1 indicates single-word return */
(gdb) x 0x7fff7608
0x7fff7608: 0x00000000
(gdb) n
384 RETURN
(gdb) x 0x7fff7608
0x7fff7608: 0x00000000
[b](gdb) n
CVMjniInvokeNative () at ../../src/mips/javavm/runtime/invokeNative_mips.S:387
387 swc1 $f0, (a3)
(gdb) x 0x7fff7608
0x7fff7608: 0x00000000 <---- the returnValue is 0
(gdb) n
388 li v0, 1 /* 1 indicates single-word return */
(gdb) x 0x7fff7608
0x7fff7608: 0xffffffff <--- the returnValue changed to -1[/b]
(gdb) p /x $f0
$7 = 0x1
(gdb) n
389 RETURN
(gdb) x 0x7fff7608
0x7fff7608: 0xffffffff

(gdb) n
395 sw v0, 0(a3)
(gdb) x 0x7fff7608
0x7fff7608: 0xffffffff
(gdb) n
396 sw v1, 4(a3)
(gdb) info registers
zero at v0 v1 a0 a1 a2 a3
R0 00000000 2aff9a28 00000001 00000000 00001000 2b00d890 00000000 7fff7608
t0 t1 t2 t3 t4 t5 t6 t7
R8 10001a5c 2b00d8e4 00000004 00000000 7fff75bc 40000000 1000023c 40000000
s0 s1 s2 s3 s4 s5 s6 s7
R16 00000028 2aaffef8 00401d80 100077e8 10012808 0000006c 10012c08 00000000
t8 t9 k0 k1 gp sp s8 ra
R24 00000b2b 2af90338 2b01cf95 00000000 2b266500 7fff75d0 7fff75e0 2aebe618
sr lo hi bad cause pc
00000000 00004a90 00000000 2b004c68 00000024 2b00d8b4
fsr fir
00000000 00000000
(gdb) x 0x7fff7608
0x7fff7608: 0x00000001
(gdb) x 0x7fff760C
0x7fff760c: 0x7fff76f8
(gdb) n
398 li v0, 2 /* 2 indicates double-word return */
(gdb) x 0x7fff760C
0x7fff760c: 0x00000000
(gdb) n
399 RETURN
(gdb) info registers
zero at v0 v1 a0 a1 a2 a3
R0 00000000 2aff9a28 00000002 00000000 00001000 2b00d890 00000000 7fff7608
t0 t1 t2 t3 t4 t5 t6 t7
R8 10001a5c 2b00d8e4 00000004 00000000 7fff75bc 40000000 1000023c 40000000
s0 s1 s2 s3 s4 s5 s6 s7
R16 00000028 2aaffef8 00401d80 100077e8 10012808 0000006c 10012c08 00000000
t8 t9 k0 k1 gp sp s8 ra
R24 00000b2b 2af90338 2b01cf95 00000000 2b266500 7fff75d0 7fff75e0 2aebe618
sr lo hi bad cause pc
00000000 00004a90 00000000 2b004c68 00000024 2b00d8bc
fsr fir
00000000 00000000

(gdb) n
405 swc1 $f1, 0(a3)
(gdb) info registers
zero at v0 v1 a0 a1 a2 a3
R0 00000000 2aff9a28 00000002 00000000 00001000 2b00d890 00000000 7fff7608
t0 t1 t2 t3 t4 t5 t6 t7
R8 10001a5c 2b00d8e4 00000004 00000000 7fff75bc 40000000 1000023c 40000000
s0 s1 s2 s3 s4 s5 s6 s7
R16 00000028 2aaffef8 00401d80 100077e8 10012808 0000006c 10012c08 00000000
t8 t9 k0 k1 gp sp s8 ra
R24 00000b2b 2af90338 2b01cf95 00000000 2b266500 7fff75d0 7fff75e0 2aebe618
sr lo hi bad cause pc
00000000 00004a90 00000000 2b004c68 00000024 2b00d8c4
fsr fir
00000000 00000000
(gdb) x 0x7fff7608
0x7fff7608: 0x00000001
(gdb) p /x $f1
$8 = 0x1
(gdb) n
406 swc1 $f0, 4(a3)
(gdb) x 0x7fff7608
0x7fff7608: 0xffffffff
(gdb) x 0x7fff760C
0x7fff760c: 0x00000000
(gdb) n
413 li v0, 2 /* 2 indicates double-word return */
(gdb) x 0x7fff760C
0x7fff760c: 0xffffffff
(gdb) n
414 RETURN
(gdb) n
417 li v0, 0 /* 0 indicates void return */
(gdb) n
418 RETURN

(gdb) n
CVMinvokeJNIHelper (ee=0x2b262fb8, mb=0x2b27c5a0)
at ../../src/share/javavm/runtime/interpreter.c:4077
4077 CVMassert(ee->criticalCount == 0);
(gdb) p /x returnValue.jni
$9 = {i = 0xffffffff, f = 0x1, v64 = {0xffffffff, 0xffffffff}, o = 0xffffffff}

This is the first time to run into CVMjniInvokeNative.
If I keep tracing, it will go into CVMjniInvokeNative again.
But it seems go to Java_java_lang_Object_wait, and hang forever.
(gdb) n
289 NEXT_ARG
(gdb) n
327 LOADI a2, 2*ARGSIZE(sp)
(gdb) x 0x7fff7608
0x7fff7608: 0xffffffff
(gdb) n
328 LOADI a3, 3*ARGSIZE(sp)
(gdb) x 0x7fff7608
0x7fff7608: 0xffffffff
(gdb) n
347 jalr FuncPtr
(gdb) p /x $t9
$12 = 0x2af4ee0c
(gdb) x 0x2af4ee0c
0x2af4ee0c : 0x3c1c0031
(gdb) x 0x7fff7608
0x7fff7608: 0xffffffff

Hope this log can provide some information. Look forward to your suggestion.
Really appreciate for your help. Thank you.

sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi, Chris:
I have a finding but I don't know why.
Here is the code in invokeNative_mips.S. I list line 347 to line 389.

[i]347 jalr FuncPtr
348
349 /* 2007/08/23 */
350 lw gp, __gp(fp) /* we restore the gp from the stack */
351
352 LA(SWITCHBASE, $ret_jumps)
353
354 lw a3, stk3 /* pointer to result buffer */
355
356 /*
357 * thread the return address to the
358 * proper code for our return type
359 */
360
361 sll RETTYPE, 2
362 addu a1, SWITCHBASE, RETTYPE
363 lw a1, (a1)
364 move sp, fp
365 jr a1
366
367#define RETURN \
368 lw ra, _ra(sp); \
369 lw fp, _fp(sp); \
370 /* 2007/08/23 */
371 lw gp, __gp(sp); \
372 lw s0, _s0(sp); \
373 addiu sp, framesize; \
374 jr ra; \
375
376$ret_obj:
377 sw v0, (a3)
378 li v0, -1 /* -1 indicates object return */
379 RETURN
380
381$ret_s32:
382 sw v0, (a3)
383 li v0, 1 /* 1 indicates single-word return */
384 RETURN
385
386$ret_f32:
387 swc1 $f0, (a3)
388 li v0, 1 /* 1 indicates single-word return */
389 RETURN[/i]

I found in my case, the code will execute from line 347 to line 365.
Next it will jump to line 382 and execute to line 384.
But after execute line 384, it doesn't return to CVMinvokeJNIHelper.
It just keep execute line 386. The returnValue.jni in line 384 is zero.
But after execute line 386, returnValue.jni will be changed to -1.
That's why the returnValue.jni will be change to -1.
I guess maybe there is something wrong in RETURN.
Could you please give me some suggestion?
Thank you very much.

cjplummer
Offline
Joined: 2006-10-16
Points: 0

In both cases your are having problems with the RETURN macro. It is suppose to return you to CVMJNIinvokeHelper after having executed the code at one of the $ret_XXX labels. However, in your first example, after the code at $ret_s32 was correctly executed, RETURN then placed you at the $ret_f32 label, which stored a float result. Subsequent executions of the RETURN macro sent you to a few other $ret_XXX labels before finally returning you to CVMJNIinvoekHelper. The 2nd case looks similar, but it appears you just bound around between $ret_XXX labels.

I think what you need to do next is step through the RETURN macro using the si macros, so you step on mips insrtruction at a time, rather than one source line at a time. Use "x /i" to display the instructions. For example:

x /8i $pc

should display the next 8 instructions. You can also use a label or address in place of $pc.

BTW, you can ingore the 2nd JNI invocation that puts you in Object.wait(). This is happening because the first invocation is not properly returning false, which results in Class.runStaticInitializers deciding that Object.wait() shold be called, which will result in waiting for a notify that will never happen.

good luck,

Chris

sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi, Chris:
I can't jump in RETURN using "si".
Here is gdb log. It seems doesn't run into RETURN.

(gdb) n
390 RETURN
(gdb) x 0x2b266500
0x2b266500 : 0x00000000
(gdb) si
0x2b00d89c 390 RETURN
(gdb) x /8i $pc
0x2b00d89c : lw s8,8(sp)
0x2b00d8a0 : swc1 $f0,0(a3)
0x2b00d8a4 : li v0,1
0x2b00d8a8 : lw ra,12(sp)
0x2b00d8ac : lw s8,8(sp)
0x2b00d8b0 : sw v0,0(a3)
0x2b00d8b4 : sw v1,4(a3)
0x2b00d8b8 : li v0,2

Any idea about this? Thank you.

cjplummer
Offline
Joined: 2006-10-16
Points: 0

What happens when you use si? It is probably working. Do a "x /i $pc" after each si and you'll see the $pc is moving forward.

From your output, it looks like the RETURN macro is broken. It should contain the following:

#define RETURN \
lw ra, _ra(sp); \
lw fp, _fp(sp); \
lw s0, _s0(sp); \
addiu sp, framesize; \
jr ra; \

If you applied the patch I sent, it would look like:

#define RETURN \
lw ra, _ra(sp); \
lw fp, _fp(sp); \
lw gp, __gp(sp); \
lw s0, _s0(sp); \
addiu sp, framesize; \
jr ra; \

However, I don't see the last 4 instructions from the macro in your output, which I believe has the very end of $ret_s32, all of $ret_f32, and the start of $ret_s64. I suggest you make sure you did not do any unintentional edits to RETURN that are resulting in the line continuation character not working. Any spaces located after the \ will mess things up. If you can't see a problem, try making the macro all one line and get rid of all the \'s.

Chris

sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi, Chris:
Thank you very much.
I found I add one line comment before the third instruction in RETURN.
And I don't add "\" at end of the comment.
After I add "\" at that line and run again.
CVM can run on my target board.
Really appreciate for your great help.
Thank you.

cjplummer
Offline
Joined: 2006-10-16
Points: 0

> Hi, Mark:
> After a more detail tracing between one cvm and
> cvm+so, I found the crash point.
> But I dont know the reason.
> [b]In invokeNative_mips.S: line 210 -->
> LA(SWITCHBASE, $arg_jumps) /* load the base of the
> jump table */[/b]
>
> [b]Case 1:in one cvm executable:[/b] the value of
> SWITCHBASE is accessible.
> [b]Case 2:in cvm+so:[/b] the value of SWITCHBASE is
> not accessible, it will cause "cannot access memory"
> in gdb.
>
> I guess the address of $arg_jumps is different
> between one cvm and cvm+so.
> 1. What's the value of $arg_jumps in one cvm and in
> libcvm.so?
> 2. How to display it in gdb?
> I got stuck here.
> Is there any suggestion? Thanks for your kindly reply.

Disassemble this instruction from gdb using the "x /4i" command. You can also use the dumpobj tool (make sure you use the one meant for you mips target, not you host). It probably is not doing the right thing for determining the address of the $arg_jumps table. Note that one of the things the LA macro is suppose to handle is proper computation of globals based on the object model. Currently it contains:

#ifdef __PIC__
#define LA(r,sym) \
lui r, %hi(sym); \
addiu r, %lo(sym)
#else
#define LA(r,sym) \
la r, sym
#endif

I noticed for our internal builds, it is using the lui/addiu variant. This is probably what your build is using also, but may not be correct when building cvm as a shared library.

Chris

sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi, Mark and Chris:
Thanks for your reply. Here is the debug result.

1. I can't use "x /10i arg_jumps". gdb will return "No symbol 'arg_jumps' in current context." and I found there is no arg_jumps in symbol table of libcvm.so.(objdump -t lib/libcvm.so)

2. Yes. I also use
lui r, %hi(sym)
addiu r, %lo(sym)
in my build.

2. [b]in libcvm.so case[/b]: the output of "objdump -T lib/libcvm.so"-> I found CVMjniInvokeNative in the following line.

[b]002c1900 g DF .text 000002ac Base CVMjniInvokeNative[/b]

But when I try to "x /10i 0x002c1900", gdb returns "[b]Can't access memory at address 0x2c1900[/b]".

3. [b]in one cvm executable[/b]: the output of "objdump -T bin/cvm"-> I found CVMjniInvokeNative in the following line.

[b]005b4a30 g DF .text 000002b0 Base CVMjniInvokeNative[/b]

But when I try to "x /10i 0x005b4a30", gdb returns

0x5b4a30 : addiu sp,sp,-16
0x5b4a34 : sw ra,12(sp)
0x5b4a38 : sw s8,8(sp)
0x5b4a3c : sw s0,0(sp)
0x5b4a40 : move s8,sp
0x5b4a44 : move t9,a1
0x5b4a48 : move t0,a2
0x5b4a4c : lw t3,0(a3)
0x5b4a50 : addiu a3,a3,4
0x5b4a54 : andi s0,t3,0xf

It seems CVMjniInvokeNative got a wrong base address. Is there any way to change this or how to fix this? Really appreciate for your great help. Thanks.

cjplummer
Offline
Joined: 2006-10-16
Points: 0

I think I have a fix for you, but it will have to wait until tomorrow before I can confirm a couple of things with a colleague. Basically it has to do with properly setting up gp, and slightly changing how $ret_jumps and $arg_jumps are referenced.

Chris

sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi, Chris:
Thank you very much. Look forward to your fix.

cjplummer
Offline
Joined: 2006-10-16
Points: 0

Try applying the following diff. I'm not sure why -fno-unit-at-a-time is needed, but the JIT crashes without it so for now it is needed as a workaround. If the formatting of the diff gets messed up by the forum software (which is likely), it should be pretty simple to just manually apply the changes, or I can send them via email.

Chris

Index: src/linux-mips/javavm/include/asmmacros_arch.h
===================================================================
--- src/linux-mips/javavm/include/asmmacros_arch.h (revision 6989)
+++ src/linux-mips/javavm/include/asmmacros_arch.h (working copy)
@@ -38,13 +38,7 @@
#define ENTRY(x) LEAF(x)
#define SET_SIZE(x) END(x)

-#ifdef __PIC__
#define LA(r,sym) \
- lui r, %hi(sym); \
- addiu r, %lo(sym)
-#else
-#define LA(r,sym) \
la r, sym
-#endif

#endif /* _INCLUDED_ASMMACROS_ARCH_H */
Index: src/mips/javavm/runtime/invokeNative_mips.S
===================================================================
--- src/mips/javavm/runtime/invokeNative_mips.S (revision 6989)
+++ src/mips/javavm/runtime/invokeNative_mips.S (working copy)
@@ -190,6 +190,7 @@

sw ra,_ra(sp)
sw fp,_fp(sp)
+ sw gp,__gp(sp)
sw s0,_s0(sp)

move fp, sp
@@ -349,6 +350,7 @@

jalr FuncPtr

+ lw gp, __gp(fp) /* we restore the gp from the stack */
LA(SWITCHBASE, $ret_jumps)

lw a3, stk3 /* pointer to result buffer */
@@ -367,6 +369,7 @@
#define RETURN \
lw ra, _ra(sp); \
lw fp, _fp(sp); \
+ lw gp, __gp(sp); \
lw s0, _s0(sp); \
addiu sp, framesize; \
jr ra; \
Index: build/linux-mips-cobalt/GNUmakefile
===================================================================
--- build/linux-mips-cobalt/GNUmakefile (revision 6989)
+++ build/linux-mips-cobalt/GNUmakefile (working copy)
@@ -32,7 +32,7 @@
# platform specific architecture flags
#
ASM_ARCH_FLAGS = -mips2
-CC_ARCH_FLAGS = -mips2
+CC_ARCH_FLAGS = -mips2 -fno-unit-at-a-time
# Fix gcc fp extra precision bug on mips
CC_ARCH_FLAGS_FDLIB = -ffloat-store
CC_ARCH_FLAGS_LOOP =

sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi, Chris:
Thank you for your fix. I have already patch this. Signal 11 seems fixed.
But CVM is still hang at different place. I tried two builds: one cvm and cvm + libcvm.so. And these two cases are the same. They both hang at the same place.
It seems cause thread waiting for something.
Is there any suggestion about this? Really appreciate for your knidly help.
Thank you.
Here is the stack backtrace.

#0 __pthread_cond_wait (cond=0x2b2630b0, mutex=0x2b263094)
at ../nptl/sysdeps/pthread/pthread_cond_wait.c:146
#1 0x2afe13b0 in CVMcondvarWait (c=0x10003240, m=0x10003228, millis=0)
at ../../src/linux/javavm/runtime/sync_md.c:366
#2 0x2aed9630 in CVMreentrantMutexWait (ee=0x2b262fc8, rm=0x10003220,
c=0x10003240, millis=0) at ../../src/share/javavm/runtime/sync.c:152
#3 0x2aed9980 in CVMsysMonitorWait (ee=0x2b262fc8, mon=0x10003220, millis=0)
at ../../src/share/javavm/runtime/sync.c:238
#4 0x2aec32b8 in CVMprivateWait (ee=0x2b262fc8, indirectObj=0x10001a4c,
millis=0, fast=1) at ../../src/share/javavm/runtime/objsync.c:1727
#5 0x2aec38d0 in CVMfastWait (ee=0x2b262fc8, indirectObj=0x10001a4c, millis=0)
at ../../src/share/javavm/runtime/objsync.c:1784
#6 0x2aec9638 in CVMgcSafeObjectWait (ee=0x2b262fc8, o=0x10001a4c, millis=0)
at ../../src/share/javavm/runtime/objsync.c:3174
[b]#7 0x2af4eeb8 in Java_java_lang_Object_wait (env=0x2b262ff4, obj=0x10001a4c,
millis=0) at ../../src/share/javavm/runtime/jvm.c:1617
#8 0x2b00d854 in CVMjniInvokeNative ()
at ../../src/mips/javavm/runtime/invokeNative_mips.S:347
#9 0x2aebe630 in CVMinvokeJNIHelper (ee=0x2b262fc8, mb=0x2b27c7b4)
at ../../src/share/javavm/runtime/interpreter.c:4062[/b]
#10 0x2b00a3dc in CVMgcUnsafeExecuteJavaMethod (ee=0x2b262fc8, mb=0x2b27c7b4,
isStatic=0, isVirtual=0)
at ../../src/share/javavm/runtime/executejava_standard.c:3480
#11 0x2af38ed4 in CVMjniInvoke (env=0x2b262ff4, obj=0x2b1ee344,
methodID=0x2b27c6c0, pushArguments=0x2af37b54 ,
args=0x7fff7978, info=258, retValue=0x0)
at ../../src/share/javavm/runtime/jni_impl.c:2622
#12 0x2af3c3f4 in CVMjniCallVoidMethod (env=0x2b262ff4, obj=0x2b1ee344,
methodID=0x2b27c6c0) at ../../src/share/javavm/runtime/jni_impl.c:2842
#13 0x2aefcd5c in CVMprivateClassInit (ee=0x2b262fc8, cb=0x2b214984, p_mb=0x0)
at ../../src/share/javavm/runtime/classinitialize.c:170
#14 0x2aefc674 in CVMclassInit (ee=0x2b262fc8, cb=0x2b214984)
at ../../src/share/javavm/runtime/classinitialize.c:43
#15 0x2af3c914 in initializeClassList (ee=0x2b262fc8,
errorStrBuf=0x7fff7af0 "*\uffff\t`\177\uffff{.*\uffff\200", sizeofErrorStrBuf=256,
classList=0x2b25dde4, numClasses=8)
at ../../src/share/javavm/runtime/jni_impl.c:3190
#16 0x2af3d0c8 in initializeSystemClasses (env=0x2b262ff4,
errorStrBuf=0x7fff7af0 "*\uffff\t`\177\uffff{.*\uffff\200", sizeofErrorStrBuf=256,
initArgs=0x10001840, numUnrecognizedOptions=2)
at ../../src/share/javavm/runtime/jni_impl.c:3558
#17 0x2af3e154 in JNI_CreateJavaVM (p_jvm=0x7fff7c40, p_env=0x7fff7c60,
args=0x10001840) at ../../src/share/javavm/runtime/jni_impl.c:4007
#18 0x004019fc in ansiJavaMain (argc=4, argv=0x7fff7d74,
JNI_CreateJavaVMFunc=0x2af3d1e8 )
at ../../src/portlibs/ansi_c/ansi_java_md.c:331
#19 0x00400ca0 in main (argc=4, argv=0x7fff7d74)
at ../../src/linux/bin/java_md.c:41

sschang123
Offline
Joined: 2007-07-05
Points: 0

Sorry. I forgot to say my target is "big endian".
Will this affect the result?
Thanks.

cjplummer
Offline
Joined: 2006-10-16
Points: 0

Big endian is fine, although not well tested like little endian is. I just did a quick test on a big endian machine and didn't see any problems.

Chris

sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi, Mark:
After a more detail tracing between one cvm and cvm+so, I found the crash point.
But I dont know the reason.
[b]In invokeNative_mips.S: line 210 --> LA(SWITCHBASE, $arg_jumps) /* load the base of the jump table */[/b]

[b]Case 1:in one cvm executable:[/b] the value of SWITCHBASE is accessible.
[b]Case 2:in cvm+so:[/b] the value of SWITCHBASE is not accessible, it will cause "cannot access memory" in gdb.

I guess the address of $arg_jumps is different between one cvm and cvm+so.
1. What's the value of $arg_jumps in one cvm and in libcvm.so?
2. How to display it in gdb?
I got stuck here.
Is there any suggestion? Thanks for your kindly reply.

mlam
Offline
Joined: 2006-10-13
Points: 0

sschang,
Try googling for "gdb tutorial" and you will find a number of articles that can perhaps answer your questions better regarding how you do things in gdb. I'll help answer a few quick ones here:

> Hi, Mark:
> After a more detail tracing between one cvm and
> cvm+so, I found the crash point.
> But I dont know the reason.
> [b]In invokeNative_mips.S: line 210 -->
> LA(SWITCHBASE, $arg_jumps) /* load the base of the
> jump table */[/b]

According to the source code, SWITCHBASE is #define to be t1. I presume t1 is a MIPS register (I'm not a MIPS expert). Try "p /x $t1" to see what it is set to.

> [b]Case 1:in one cvm executable:[/b] the value of
> SWITCHBASE is accessible.
> [b]Case 2:in cvm+so:[/b] the value of SWITCHBASE is
> not accessible, it will cause "cannot access memory"
> in gdb.

Same as above.

> I guess the address of $arg_jumps is different
> between one cvm and cvm+so.
> 1. What's the value of $arg_jumps in one cvm and in
> libcvm.so?

Try "p /x arg_jumps" to see the value/address of arg_jumps.
Try "x /10i arg_jumps" to see the instructions that are at arg_jumps. They should be the same regardless of CVM being in a .so or not.

> 2. How to display it in gdb?

The gdb "p" command is short for "print". I've give you instructions on using it for various purposes so far. I suggest you look up a tutorial on gdb to learn more about what you can do with it. This will help your debugging.

Mark

Fixed mistake: changed "p /10i arg_jumps" to "x /10i arg_jumps".

Message was edited by: mlam

sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi, Mark:
After tracing, I found it crashed at line 246 in invokeNative_mips.S.
If I try to dump memory adress (a2), it will show "Can't access memory" in gdb.
But a2 seems equal SWITCHBASE+SIGBYTE, and SWITCHBASE equals $arg_jumps in line 210. I have no idea about this. Is there any different in between one cvm executable and cvm+libcvm.so? That's all I found now. Look forward to your suggestion. Thank you.

#define NEXT_ARG \
andi SIGBYTE, SIGBUFF, TYPEMASK; \
sll SIGBYTE, 2; \
addu a2, SWITCHBASE, SIGBYTE; \
lw a2, (a2); \ <---- it will crash here.
srl SIGBUFF, TYPESHIFT; \
jr a2;

mlam
Offline
Joined: 2006-10-13
Points: 0

sschang,

CVMjniInvokeNative() is responsible for marshalling method args, calling a native method, and marshalling the return value. In this case, the section of code you are looking at is doing the marshalling of method args i.e. it is taking method args from the Java stack and putting it onto the native stack in preparation for calling the native method.

The way it knows what the type of args the method has is by looking at the signature of the method which is pointed to by SIGBUFF. SIGBYTE contains the type of the current arg being marshalled. SWITCHBASE is the base address of a table of pointers of handler code that will marshall each type of arg type (see $arg_jumps).

The code excerpt you quoted is doing the following work:

andi SIGBYTE, SIGBUFF, TYPEMASK; // Get the type of the current arg.
sll SIGBYTE, 2; // Convert the arg type into an index into the $arg_jumps table.
addu a2, SWITCHBASE, SIGBYTE; // Compute address of the arg type handler.
lw a2, (a2); <---- it will crash here. // Load the address of the handler.
srl SIGBUFF, TYPESHIFT; // Setup the argslist for the next arg.
jr a2; // Jump to the handler.

Any number of things could have happened to cause the above crash. Based on the above logic, you'll need to step through the code an instruction at a time and see why the above code wouldn't work when you build CVM as a .so.

My guess is that being a .so, one or some of the registers that are used in this code is also used by the OS for some data / code pointer of the .so. As a result, the values the above code is using may get trashed. You'll have too do some further debugging to see what went wrong here and which register value got corrupted, and why.

Let us know what you find.

Mark

sschang123
Offline
Joined: 2007-07-05
Points: 0

Mark:
Really appreciate for your reply. It's very clear.
I will try to figure out what happen in that code segment.
One more question is how to step trace assembly code in gdb?
Should I turn on any definition besides setting CVM_DEBUG=true?
Thank you.

mlam
Offline
Joined: 2006-10-13
Points: 0

sschang,

To step a single machine instruction in gdb, use "si". As for build options, for the section of code you are debugging, I don't think I need to add any particular options. CVM_DEBUG=true is obviously a good option to have in case you need to use some debugging facilities in the VM. But right now, I don't think CVM_DEBUG will not affect the region of cod you need to look at.

Mark

sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi, Mark:
Thank you. I found I have to add "-g" in ASM_FLAGS in share/defs.mk and I can trace assembly in gdb. Because set CVM_DEBUG=true doesn't add "-g" in ASM_FLAGS, so I can't trace assembly codes in gdb. Maybe Sun can improve this in makefile. I am still in tracing assembly codes in gdb. no new finding right now. Thanks.

sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi, is anybody here?
I've collected the stack trace in gdb. Hope somebody can give me suggestion. Thank you.

#0 0x2b0091e4 in CVMjniInvokeNative () from ./lib/libcvm.so
#1 0x2aeb9e18 in CVMinvokeJNIHelper (ee=0x2b252a08, mb=0x2b26b494)
at ../../src/share/javavm/runtime/interpreter.c:4062
#2 0x2b005e5c in CVMgcUnsafeExecuteJavaMethod (ee=0x2b252a08, mb=0x2b26b494,
isStatic=0, isVirtual=0)
at ../../src/share/javavm/runtime/executejava_standard.c:3480
#3 0x2af34814 in CVMjniInvoke (env=0x2b252a34, obj=0x2b1e0980,
methodID=0x2b26b5a4, pushArguments=0x2af33494 ,
args=0x7fff7970, info=258, retValue=0x0)
at ../../src/share/javavm/runtime/jni_impl.c:2622
#4 0x2af37d34 in CVMjniCallVoidMethod (env=0x2b252a34, obj=0x2b1e0980,
methodID=0x2b26b5a4) at ../../src/share/javavm/runtime/jni_impl.c:2842
#5 0x2aef8674 in CVMprivateClassInit (ee=0x2b252a08, cb=0x2b2061a8, p_mb=0x0)
at ../../src/share/javavm/runtime/classinitialize.c:183
#6 0x2aef7f14 in CVMclassInit (ee=0x2b252a08, cb=0x2b2061a8)
at ../../src/share/javavm/runtime/classinitialize.c:44
#7 0x2af382a4 in initializeClassList (ee=0x2b252a08,
errorStrBuf=0x7fff7af0 "*?\t`\177?{.*?\200", sizeofErrorStrBuf=256,
classList=0x2b24d9a4, numClasses=8)
at ../../src/share/javavm/runtime/jni_impl.c:3191
#8 0x2af38b0c in initializeSystemClasses (env=0x2b252a34,
errorStrBuf=0x7fff7af0 "*?\t`\177?{.*?\200", sizeofErrorStrBuf=256,
initArgs=0x100018a0, numUnrecognizedOptions=2)
at ../../src/share/javavm/runtime/jni_impl.c:3563
#9 0x2af39b98 in JNI_CreateJavaVM (p_jvm=0x7fff7c40, p_env=0x7fff7c60,
args=0x100018a0) at ../../src/share/javavm/runtime/jni_impl.c:4050
#10 0x00401c38 in ansiJavaMain (argc=4, argv=0x7fff7d74,
JNI_CreateJavaVMFunc=0x2af38c2c )
at ../../src/portlibs/ansi_c/ansi_java_md.c:347
#11 0x00400dfc in main (argc=4, argv=0x7fff7d74)
at ../../src/linux/bin/java_md.c:44

mlam
Offline
Joined: 2006-10-13
Points: 0

Hi sschang,

According to the gdb backtrace, it appears that you crashed in the assembly code in CVMjniInvokeNative(). Since you are running MIPS port, you would be using the version in src/mips/javavm/runtime/invokeNative_mips.S. There's not much we can do to help you here. You need to do some debugging to find out what it causing the signal 11. One thing you can do in gdb is:

> p /x $pc
> x /10i $pc-16

The first command prints the current program counter (PC) value. The second dumps the assembly instructions from 4 instructions back till 6 instructions after the current PC address. Correlate that with the source code in invokeNative_mips.S to try and figure out what is causing the segfault (a.k.a. signal 11).

The phoneME Advanced MIPS code has always been used to build a binary executable. Hence, it has never been tested as a .so. I don't know what modifications you made to build it as a .so. Bear in mind that code generated for .so's need to be relocatable in some form, and executables do not. While some appropriate compiler options can automatically cause gcc to generate the needed relocatable code for the C files, it probably won't do anything for the assembly code in invokeNative_mips.S. Chances are, your OS is expecting .so code to appear in some form that the invokeNative code isn't in yet. You'll have to find out what that mismatch is. Let us know if you find out more details.

Good luck.

Regards,
Mark

sschang123
Offline
Joined: 2007-07-05
Points: 0

Hi, Mark:
Thank you very much. Your reply is very helpful for me.
I will try to trace this. Any progress I will let you know.
Thanks.