Dalvik VM init failed (check log file)

350 views
Skip to first unread message

anand@android

unread,
Mar 24, 2009, 11:09:00 AM3/24/09
to android-porting
Hi All,

I'm trying to port dalvik VM onto PPC.
I could able to build 'dalvikvm' binary and the respective 'jar' files
that are needed for the execution of 'dalvikvm'('core.jar' ,
'ext.jar','framework.jar',android.policy.jar' and 'services.jar')

To test dalvikvm i followed the following steps:-

1:
export LD_LIBRARY_PATH=/home/cupcake/out/debug/target/product/eee_701/
system/lib
2:
export ANDROID_ROOT=/home/cupcake/out/debug/target/product/eee_701/
system
3:
export BOOTCLASSPATH=/home/cupcake/out/debug/target/product/eee_701/
systemframework/core.jar:/home/cupcake/out/debug/target/product/
eee_701/system/framework/ext.jar:/home/cupcake/out/debug/target/
product/eee_701/system/framework/framework.jar
4:
export ANDROID_DATA=/tmp/dalvik_$USER
mkdir -p $ANDROID_DATA/dalvik-cache
5:
$cat Foo.java
public class Foo {
public static void main(String[] args) {
System.out.println("Hello, world");
}
}

$javac Foo.java
$dx --dex --output=foo.jar Foo.class
6:
$./dalvikvm -cp foo.jar Foo


For the first execution of 'dalvikvm' I got segmentation fault.
On debugging in gdb I found where it was crashing.
To fix it I made modification in the following file
'dalvik/vm/mterp/common/asm-constants.h'
Line No :186

ORIGINAL-> MTERP_OFFSET(offArrayObject_contents, ArrayObject,
contents, 12)
MODIFIED-> MTERP_OFFSET(offArrayObject_contents, ArrayObject,
contents, 16)

Reason:-
'contents' member in ArrayObject structure is a 64-bit entity and
there are three 32-bit entities above it.
For satisfying 64-bit alignment 'contents' member should start at 16
byte offset rather than 12 byte.

After making the above change, I followed the same steps to execute
dalvikvm,
but this time i didnt get the seg fault but one message came up saying
"Dalvik VM init failed (check log file)".

On debugging in gdb I found the error line to be at
system/core/libcutils/ashmem-dev.c:60 ret = ioctl(fd,
ASHMEM_SET_SIZE, size)
; -- with errno set to -ENOTTY.

I really need help on this to go ahead

Thanks in advance
Anand





fadden

unread,
Mar 24, 2009, 7:05:28 PM3/24/09
to android-porting
On Mar 24, 8:09 am, "anand@android" <android.an...@gmail.com> wrote:
> ORIGINAL->  MTERP_OFFSET(offArrayObject_contents,   ArrayObject,
> contents, 12)
> MODIFIED->  MTERP_OFFSET(offArrayObject_contents,   ArrayObject,
> contents, 16)

See MTERP_NO_UNALIGN_64 in the current version:

http://android.git.kernel.org/?p=platform/dalvik.git;a=blob;f=vm/mterp/common/asm-constants.h;h=73292a9f2a5863fe55b3d524695f245388ad1780;hb=HEAD

> but this time i didnt get the seg fault but one message came up saying
> "Dalvik VM init failed (check log file)".
>
> On debugging in gdb I found the error line to be at

The log file will usually provide some useful info. Do you have /dev/
log working?

> system/core/libcutils/ashmem-dev.c:60    ret = ioctl(fd,
> ASHMEM_SET_SIZE, size)
> ; -- with errno set to -ENOTTY.

Do you have the ashmem driver working?

Anand Android

unread,
Mar 26, 2009, 12:31:21 PM3/26/09
to android...@googlegroups.com
Hi fadden , thanks for the reply.

i have fixed 'ashmem' issue and am able to proceed till 'dexopt' tries to optimize the jar file,which is failing with following error.
-------------
DexOpt:  locked cache file
DexOpt: successfully initialized new cache file
DexOpt: --- BEGIN 'core.jar' (bootstrap=1) ---
DexOpt: waiting for verify+opt, pid=2460
Continuing optimization (/home/cupcake/out/debug/target/product/eee_701/system/framework/core.jar, isb=1, vfy=1, opt=1)
+++ swapping bytes
DexOpt: --- END 'core.jar' --- status=0xff00, process failed
Unable to extract+optimize DEX from '/home/cupcake/out/debug/target/product/eee_701/system/framework/core.jar'
--------------

On debugging i found it is failing at '~/cupcake/dalvik/libdex/DexSwapVerify.c:2084' where 'swapMap()' function is failing.


Thanks in advance
Ananda




fadden

unread,
Mar 26, 2009, 7:25:59 PM3/26/09
to android-porting
On Mar 26, 9:31 am, Anand Android <android.an...@gmail.com> wrote:
> DexOpt: --- BEGIN 'core.jar' (bootstrap=1) ---
> DexOpt: waiting for verify+opt, pid=2460
> Continuing optimization
> (/home/cupcake/out/debug/target/product/eee_701/system/framework/core.jar,
> isb=1, vfy=1, opt=1)
> +++ swapping bytes
> DexOpt: --- END 'core.jar' --- status=0xff00, process failed
[...]
> On debugging i found it is failing at
> '~/cupcake/dalvik/libdex/DexSwapVerify.c:2084' where 'swapMap()' function is
> failing.

It should log a specific failure message when something goes wrong.
Line 2084 looks like it's scrounging around in annotations; I think
maybe it should have a LOGE:

while (size--) {
data = verifyEncodedValue(state, data, crossVerify);
if (data == NULL) {
LOGE("Bogus encoded_array value\n");
return NULL;
}
}

If you've got the latest cupcake you should have the checksum
verification enabled (around line 2767), which should ensure that
you're not reading a corrupt file.

Anand Android

unread,
Mar 30, 2009, 11:57:37 AM3/30/09
to android...@googlegroups.com
hi Fadden,
thanks for the reply
I am able to proceed swapMap() function by fixing an endian issue in that function.
Fix: pMap->size has to be converted to big-endian before assigning it to count variable.

Now I have another issue in crossVerifyEverything() with "kDexTypeClassDefItem" switch-case. It is becoming increasingly difficult to debug this as this is tightly coupled to dex file-format. I hope I can get some pointers into fixing this issue.

Thanks
Anand

fadden

unread,
Mar 30, 2009, 3:26:34 PM3/30/09
to android-porting
On Mar 30, 8:57 am, Anand Android <android.an...@gmail.com> wrote:
> I am able to proceed swapMap() function by fixing an endian issue in that
> function.
> Fix: pMap->size has to be converted to big-endian before assigning it to
> count variable.

Aha, something like:

365c365
< u4 count = pMap->size;
---
> u4 count;
370a371,373
>
> SWAP_FIELD4(pMap->size);
> count = pMap->size;


> Now I have another issue in crossVerifyEverything() with
> "kDexTypeClassDefItem" switch-case. It is becoming increasingly difficult to
> debug this as this is tightly coupled to dex file-format. I hope I can get
> some pointers into fixing this issue.

Once upon a time the code ran on a big-endian PPC system, but the swap
& verify code got rewritten after we moved away from PPC hardware.

If it helps any, the DEX format is described in dalvik/docs/dex-
format.html.

Anand Android

unread,
Mar 31, 2009, 2:51:53 AM3/31/09
to android...@googlegroups.com
hi fadden,
yes that is exactly what i have done to fix problem in 'swapMap()' function.

is the version source tree that ran on ppc still available ?
if so,is it advisable to use it now and can you point me to that source tree ?

thanks
Anand

fadden

unread,
Apr 1, 2009, 1:18:32 PM4/1/09
to android-porting
On Mar 30, 11:51 pm, Anand Android <android.an...@gmail.com> wrote:
> is the version source tree that ran on ppc still available ?
> if so,is it advisable to use it now and can you point me to that source tree ?

Looking at the perforce history, the axe was dropped on PPC support in
June 2007.

So, no. :-|

dj

unread,
Apr 9, 2009, 3:10:43 AM4/9/09
to android-porting
hi fadden
i am also working on same environmnt and stuck in running
dalvikvm on my ppc64 linux m/c
Following is the issue that am currently facing

while debugging in gdb i found that
from the file dalvik/vm/oo/Object.h line 797
in the below function clazz->status contains CLASS_VERIFYING
instead of CLASS_VERIFIED

INLINE bool dvmIsClassVerified(const ClassObject* clazz) {
return clazz->status >= CLASS_VERIFIED;
}
thats why returnig false from this function in casuses dvmabort() to
fail at following location

0x0feacd38 in dvmAbort () at dalvik/vm/Init.c:1433
1433 *((char*)0xdeadd00d) = 38;
and here i am getting seg fault .
are you having any idea about this ,how to get rid of this problem?
please reply............
thanks in advance.

regards
DJ

fadden

unread,
Apr 9, 2009, 1:15:54 PM4/9/09
to android-porting
On Apr 9, 12:10 am, dj <dhananjayingr...@gmail.com> wrote:
> thats why returnig false from this function in casuses dvmabort() to
> fail at following location
>
> 0x0feacd38 in dvmAbort () at dalvik/vm/Init.c:1433
> 1433        *((char*)0xdeadd00d) = 38;
>  and here i am getting seg fault .
> are you having any idea about this ,how to get rid of this problem?

The VM calls dvmAbort() if it encounters a problem that it can't deal
with. The store to 0xdeadd00d is expected to crash the process.

The log file will have an indication of what went wrong.

Dhananjay Joshi

unread,
Apr 10, 2009, 2:26:54 AM4/10/09
to android...@googlegroups.com

Hi fadden
               Actually i dont know how to check messages in /dev/log directory?
               For that we need to write socket program ?
               can you please throw a light on this?
 
 
regards,
DJ

fadden

unread,
Apr 10, 2009, 1:02:56 PM4/10/09
to android-porting
On Apr 9, 11:26 pm, Dhananjay Joshi <dhananjayingr...@gmail.com>
wrote:
> > The log file will have an indication of what went wrong.

>                Actually i dont know how to check messages in /dev/log
> directory?
>                For that we need to write socket program ?
>                can you please throw a light on this?

The "logcat" command will read and display messages from the log
devices.

Dhananjay Joshi

unread,
Apr 13, 2009, 12:37:38 AM4/13/09
to android...@googlegroups.com

hi fadden
               The "logcat" command will read and display messages from the log
devices.
 
as i have android kernel running on my ppc64 m/c , on top of that am trying to run dalvikvm executable , how can i run logcat command from shell?
as it is not recognising dalvikvm's internal command.
 
regards,
DJ

Dhananjay Joshi

unread,
Apr 13, 2009, 1:48:36 AM4/13/09
to android...@googlegroups.com
also when i tried running logcat binary from command line i am getting this error
 
Unable to open log device '/dev/log/main'
 
do you know what is this talking about ?

Avtar Singh

unread,
Apr 13, 2009, 2:02:38 AM4/13/09
to android...@googlegroups.com

as i have android kernel running on my ppc64 m/c , on top of that am trying to run dalvikvm executable , how can i run logcat command from shell?
as it is not recognising dalvikvm's internal command.

Do you see the shell prompt? Type in "logcat" at the shell prompt.
 
 
also when i tried running logcat binary from command line i am getting this error
 
Unable to open log device '/dev/log/main'
 
do you know what is this talking about ?

Did you rebuild kernel by switching off the log driver in kernel configuration file? You need to have that driver enabled.

Dhananjay Joshi

unread,
Apr 14, 2009, 3:27:22 AM4/14/09
to android...@googlegroups.com




hi
    thanks for your reply.
    but i dont know this log drivers comes under which kernel module?
    which driver module i need to enable?
 
regards
DJ

Dhananjay Joshi

unread,
Apr 14, 2009, 8:46:55 AM4/14/09
to android...@googlegroups.com
Now i have enable log drivers in android kernel module,
and i can able to see /dev/log socket is generated
 
but after getting seg fault from dalvikvm when i run logcat from command line
getting the same error as
 
Unable to open log device '/dev/log/main'
 
so do you have any solution to this problem?
 
regards,
DJ
Reply all
Reply to author
Forward
0 new messages