Re: [Sablevm-developer] native libs
Brought to you by:
egagnon
From: Prof. E. M. G. <eti...@uq...> - 2003-01-22 14:33:12
|
Hi David. I had identified the problem yesterday, and I fixed it this morning. Simply check-out the CVS version. Etienne David Paul BELANGER wrote: > I was able to fix it. I was confused for quite some time by a pointer > getting "magically" the value NULL. >=20 >>From my understanding there is a bootstrap class loader and > "application" class loader(s). The native library list in the applicat= ion > class loader is initially NULL. The code in > java_lang_Runtime_nativeLoad does not check if the list is initially > NULL. The bootstrap class loader library happened not to be initially > null since is > it is initialized early with sablevm itself elsewhere. >=20 > I will clean up my code and send a patch via the bug tack system. >=20 >=20 > David >=20 > On Mon, Jan 20, 2003 at 04:21:01PM -0500, Prof. Etienne M. Gagnon wrote= : >=20 >>OK. I'm back! :-) >> >>I'll look at this tomorrow. You're on Debian/x86, right? >> >>Etienne >> >>David Paul BELANGER wrote: >> >>>Hi, >>> >>>I'm getting a segmentation fault when trying to load a native library.= >>>The system native library (libjava-lang, libjava-io) get properly load= ed >>>but when it comes to mine, it seems that the pointer passed to the >>>memory allocator is null. My library seems to get properly loaded (th= e >>>handle is non-null). >>> >>>I have included some gdb output and a simple Hello program that cause >>>the error. >>> >>>Thanks, >>>David >>> >>> >>>--- >>> >>>David B=E9langer >>>Graduate Student >>>School of Computer Science >>>McGill University >>>Office: MC226 >>> >>>Web page: http://www.cs.mcgill.ca/~dbelan2/ >>>Public key: http://www.cs.mcgill.ca/~dbelan2/public_key.txt >>> >>> >>> >>>----------------------------------------------------------------------= -- >>> >>>Program received signal SIGSEGV, Segmentation fault. >>>[Switching to Thread 1024 (LWP 10068)] >>>0x40029cbe in _svmf_cl_alloc (env=3D0x804d548, class_loader_info=3D0x8= 0636b8,=20 >>> size=3D12, ptr=3D0x0) at class_loader_memory_manager.c:139 >>>139 class_loader_memory_manager.c: No such file or directory. >>> in class_loader_memory_manager.c >>>(gdb) backtrace >>>#0 0x40029cbe in _svmf_cl_alloc (env=3D0x804d548,=20 >>>class_loader_info=3D0x80636b8, size=3D12, ptr=3D0x0) at=20 >>> class_loader_memory_manager.c:139 >>>#1 0x40029dd4 in _svmf_cl_zalloc (env=3D0x804d548,=20 >>>class_loader_info=3D0x80636b8, size=3D12, ptr=3D0x0) at=20 >>> class_loader_memory_manager.c:181 >>>#2 0x4002aab2 in _svmh_cl_zalloc_native_library (env=3D0x804d548,=20 >>> class_loader_info=3D0x80636b8, ptr=3D0x0) at cl_alloc.c:585 >>>#3 0x400890ea in Java_java_lang_Runtime_nativeLoad (_env=3D0x804d548,= =20 >>> this=3D0x8060028, _filename=3D0x8060610) at java_lang_Runtime.c:246= >>>#4 0x400df6ff in ffi_call_SYSV () from /usr/lib/libffi.so.2 >>>#5 0x400df41a in ffi_call () from /usr/lib/libffi.so.2 >>>#6 0x400334f8 in _svmf_invoke_native_nonstatic (env=3D0x804d548) at=20 >>>native.c:1171 >>>#7 0x40071b53 in _svmf_interpreter (_env=3D0x804d548) >>> at instructions_switch.c:9839 >>>#8 0x40027270 in _svmh_invoke_specific_static_clinit (env=3D0x804d548= ,=20 >>> method=3D0x4145046c) at method_invoke.c:5061 >>>#9 0x40088c9e in Java_java_lang_Class_step8 (_env=3D0x804d548,=20 >>>_class=3D0x805fd98, vmData=3D0x80607a0) at java_lang_Class.c:741 >>>#10 0x400df6ff in ffi_call_SYSV () from /usr/lib/libffi.so.2 >>>#11 0x400df41a in ffi_call () from /usr/lib/libffi.so.2 >>>#12 0x40032bf8 in _svmf_invoke_native_static (env=3D0x804d548) at=20 >>>native.c:834 >>>#13 0x40071aa4 in _svmf_interpreter (_env=3D0x804d548) >>> at instructions_switch.c:9791 >>>#14 0x4001fbaa in _svmh_invoke_nonvirtual_jlclass_initialize=20 >>>(env=3D0x804d548, this=3D0x8065b08, param_1=3D1) at method_invoke.c:35= 2 >>>#15 0x4003dcaa in _svmf_class_initialization (env=3D0x804d548,=20 >>>class=3D0x41450008) >>> at initialization.c:24 >>>#16 0x4008c6d5 in Java_java_lang_VirtualMachine_invokeMain=20 >>>(_env=3D0x804d548, _class=3D0x805fda8, mainClass=3D0x805fdb8, args=3D0= x805fdc8) >>> at java_lang_VirtualMachine.c:47 >>>#17 0x400df6ff in ffi_call_SYSV () from /usr/lib/libffi.so.2 >>>#18 0x400df41a in ffi_call () from /usr/lib/libffi.so.2 >>>#19 0x40032bf8 in _svmf_invoke_native_static (env=3D0x804d548) at=20 >>>native.c:834 >>>#20 0x40071aa4 in _svmf_interpreter (_env=3D0x804d548) >>> at instructions_switch.c:9791 >>>#21 0x40057a60 in CallStaticVoidMethod (_env=3D0x804d548, cls=3D0x805f= 198,=20 >>> methodID=3D0x41250818) at native_interface.c:14894 >>>#22 0x0804aa4d in main (argc=3D2, argv=3D0xbffff8e4) at sablevm.c:1434= >>>(gdb)=20 >>> >>> >>>----------------------------------------------------------------------= -- >>> >>> >>>public class Hello { >>> >>> static { >>> System.loadLibrary("hello"); >>> } >>> >>> private static native void printHello(); >>> >>> >>> public static void main(String[] args) { >>> printHello(); >>> } >>> >>>} >>> >>> >>>----------------------------------------------------------------------= -- >>> >>>#include "Hello.h" >>> >>>#include <stdio.h> >>> >>>JNIEXPORT void JNICALL Java_Hello_printHello >>>(JNIEnv *env, jclass c) { >>> printf("Hello!\n"); >>>} >>> >>> >>> >>>----------------------------------------------------------------------= -- >>> >>>/* DO NOT EDIT THIS FILE - it is machine generated */ >>>#include <jni.h> >>>/* Header for class Hello */ >>> >>>#ifndef _Included_Hello >>>#define _Included_Hello >>>#ifdef __cplusplus >>>extern "C" { >>>#endif >>>/* >>>* Class: Hello >>>* Method: printHello >>>* Signature: ()V >>>*/ >>>JNIEXPORT void JNICALL Java_Hello_printHello >>> (JNIEnv *, jclass); >>> >>>#ifdef __cplusplus >>>} >>>#endif >>>#endif >>> >>> >>>----------------------------------------------------------------------= -- >>> >>>all: >>> libtool gcc -c -g -o hello.lo -I../../../../include Hello.c >>> libtool gcc -o libhello.la -g hello.lo -rpath `pwd` >>> libtool install -c libhello.la `pwd`/libhello.la >> >>--=20 >>Etienne M. Gagnon, Ph.D. http://www.info.uqam.ca/~egagnon/ >>SableVM: http://www.sablevm.org/ >>SableCC: http://www.sablecc.org/ >=20 >=20 --=20 Etienne M. Gagnon, Ph.D. http://www.info.uqam.ca/~egagnon/ SableVM: http://www.sablevm.org/ SableCC: http://www.sablecc.org/ |