Re: [Jamvm-general] Error: Malloc failed - aborting VM...
Brought to you by:
rlougher
From: Robert L. <rob...@gm...> - 2006-10-23 16:22:36
|
Hi, Yes, I expected you'd get further and fail again. The problem this time is that the PowerPC 405GP doesn't support floating point (hence the illegal instruction). I expect you're cross-compiling. Can you send the output of <cross-compiler> -dumpspecs? Your tool-chain should be producing code with floating point done in software using integer instructions (i.e. -msoft-float). The problem is that there is some hand-written assembler in JamVM which handles creation of a C call-frame for calling JNI methods. This code follows the PowerPC calling-convention, and passes floating-point values in floating-point registers. On a 405GP, therefore, calling any JNI method with floating-point parameters will fail with an illegal instruction. I will need to do some experimentation to find out how the calling-convention is changed when soft-float is enabled. I expect a simple hack to treat float as int, and double as long will work but I can't gaurantee it. Apply the attached patch: cd jamvm-1.4.3/src/os/linux/powerpc patch < patch Note, as I'm in work at the moment I can't even gaurantee that this will compile (assemble)! Rob. On 10/23/06, Thanh Nguyen <TH...@te...> wrote: > Hi, > > Thanks for your quick answer. I have fixed the problem as you recommanded > below. But I got another issue. Now after loading the class > java/util/AbstractCollection, it gave me an error : Illegal instruction. > > /jamvm $ bin/jamvm HelloWorld > > /****** just a printf after : classblock->interfaces =3D (Class > **)sysMalloc(intf_count * sizeof(Class *)); ****/ > size : 16 classname : java/lang/Class, data : 268810040, file_len : 15719 > size : 0 classname : java/io/Serializable, data : 268836416, file_len : 1= 13 > size : 0 classname : java/lang/Object, data : 268836536, file_len : 1931 > size : 0 classname : java/lang/reflect/Type, data : 268838872, file_len : > 107 > size : 0 classname : java/lang/reflect/AnnotatedElement, > data : 268838992, file_len : 360 > size : 0 classname : java/lang/reflect/GenericDeclaration, > data : 268839552, file_len : 201 > size : 4 classname : java/lang/Thread, data : 268795400, file_len : 8404 > size : 0 classname : java/lang/Runnable, data : 268814600, file_len : 127 > size : 0 classname : java/lang/VMThread, data : 268821776, file_len : 148= 1 > size : 12 classname : java/lang/String, data : 268846160, file_len : 1564= 5 > size : 0 classname : java/lang/Comparable, data : 268801744, file_len : 1= 55 > size : 0 classname : java/lang/CharSequence, data : 268802088, file_len : > 257 > size : 0 classname : java/lang/Cloneable, data : 268858880, file_len : 10= 9 > size : 4 classname : java/lang/ThreadGroup, data : 268869128, file_len : > 6755 > size : 0 classname : > java/lang/Thread$UncaughtExceptionHandler, data : > 268875888, file_len : 281 > size : 16 classname : java/util/Vector, data : 268877152, file_len : 7133 > size : 4 classname : java/util/List, data : 268872776, file_len : 915 > size : 4 classname : java/util/Collection, data : 268874080, file_len : 5= 58 > size : 0 classname : java/lang/Iterable, data : 268874920, file_len : 151 > size : 0 classname : java/util/RandomAccess, data : 268874920, file_len : > 115 > size : 4 classname : java/util/AbstractList, data : 268895008, file_len : > 3074 > size : 4 classname : java/util/AbstractCollection, data : 268902192, > file_len : 2870 > > /****************************/ > > Illegal instruction > > Have you any idea about that ? > Thanks a lot for your help. > > NT > > Le lundi 23 octobre 2006 =E0 13:20 +0100, Robert Lougher a =E9crit : > Hi, A better "fix" is to change: if(mem =3D=3D NULL) { to if(mem =3D=3D NULL && > n !=3D 0) { The code doesn't try to access the returned memory if the size is > 0, and free(0) shoud do nothing... Rob. On 10/23/06, Robert Lougher > <rob...@gm...> wrote: > Hi, > > I suspect you're using uclib rather > glibc. In one or two places in > JamVM there can be calls to malloc(0), e.g. > if a class has no > interfaces. Under glibc this returns a valid pointer, > while under > uclib it doesn't. > > Easy way to "fix" is to put an extra > line at the start of sysMalloc: > > if(n =3D=3D 0) n =3D 1; > > This is a hack. > The proper fix is to remove the couple of calls to > malloc(0). I'll try and > do this for the next release. > > Rob. > > On 10/23/06, Thanh Nguyen > <TH...@te...> wrote: > > Hi all, > > > > I'm trying to use jamVM on a > plate-forme IBM Powerpc 405GP with 32MB of > > Flash and 64MB of RAM. > Actually, this plate-forme is running under > > Montavista Linux. I have > compiled the GNU Classpath 0.91 and jamvm-1.4.3 > > successfully. I have a > simple byte-code java class named HelloWold that I > > could execute > successfully with jamvm on PC Ubuntu. When I tried to execute > > it with > this command : > > #jamvm HelloWorld > > > > I got an error : Malloc failed > - aborting VM... > > > > After searching a little bit, I found that this > message is generated in the > > funtion (in alloc.c) : > > /* ------ > Allocation from system heap ------- */ > > > > void *sysMalloc(int n) { > > > void *mem =3D malloc(n); > > > > if(mem =3D=3D NULL) { > > fprintf(stderr, "Malloc > failed - aborting VM...\n"); > > exitVM(1); > > } > > > > return mem; > > > } > > > > It seems that jamvm can not intialize "Main thread" with the > function > > initialiseMainThread(java_stack) which is > defined in the > > Thread.h. At a given moment, this function calls > > > findSystemClass0("java/lang/Thread") that itself calls > > > loadSystemClass and defineClass. When defineClass is called, it loads ste= p > > > by step all java base classes like java/lang/classes, > java/io/Serializable > > etc. > > > > I found out that after loading > java/lang/classes, jamvm stopped at > > java/io/serializable and gave the > error message : Malloc failed - aborting > > VM... caused by the failure of > the execution : interfaces =3D > > classblock->interfaces =3D (Class > **)sysMalloc(intf_count * sizeof(Class *)); > > in the defineClass > function. > > > > Does anybody know about this error or got it in the > past? > > > > Thank you in advance. > > > > NT > > > > > > > > > ------------------------------------------------------------------------- > > > Using Tomcat but need to do more? Need to support web services, > security? > > Get stuff done quickly with pre-integrated technology to make > your job > > easier > > Download IBM WebSphere Application Server v.1.0.1 > based on Apache Geronimo > > > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat= =3D121642 > > > > > _______________________________________________ > > > Jamvm-general mailing list > > > Jam...@li... > > > https://lists.sourceforge.net/lists/listinfo/jamvm-general > > > > > > > > > |