Re: [Sablevm-developer] native libs
Brought to you by:
egagnon
From: Prof. E. M. G. <eti...@uq...> - 2003-01-20 21:28:40
|
OK. I'm back! :-) I'll look at this tomorrow. You're on Debian/x86, right? Etienne David Paul BELANGER wrote: > Hi, >=20 > I'm getting a segmentation fault when trying to load a native library. > The system native library (libjava-lang, libjava-io) get properly loade= d > 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 (the= > handle is non-null). >=20 > I have included some gdb output and a simple Hello program that cause > the error. >=20 > Thanks, > David >=20 >=20 > --- >=20 > David B=E9langer > Graduate Student > School of Computer Science > McGill University > Office: MC226 >=20 > Web page: http://www.cs.mcgill.ca/~dbelan2/ > Public key: http://www.cs.mcgill.ca/~dbelan2/public_key.txt >=20 >=20 >=20 > -----------------------------------------------------------------------= - >=20 > Program received signal SIGSEGV, Segmentation fault. > [Switching to Thread 1024 (LWP 10068)] > 0x40029cbe in _svmf_cl_alloc (env=3D0x804d548, class_loader_info=3D0x80= 636b8,=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, class_loader_info=3D= 0x80636b8,=20 > size=3D12, ptr=3D0x0) at class_loader_memory_manager.c:139 > #1 0x40029dd4 in _svmf_cl_zalloc (env=3D0x804d548, class_loader_info=3D= 0x80636b8,=20 > size=3D12, ptr=3D0x0) at 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, = > 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 na= tive.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, _class=3D= 0x805fd98,=20 > 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 nativ= e.c:834 > #13 0x40071aa4 in _svmf_interpreter (_env=3D0x804d548) > at instructions_switch.c:9791 > #14 0x4001fbaa in _svmh_invoke_nonvirtual_jlclass_initialize (env=3D0x8= 04d548,=20 > this=3D0x8065b08, param_1=3D1) at method_invoke.c:352 > #15 0x4003dcaa in _svmf_class_initialization (env=3D0x804d548, class=3D= 0x41450008) > at initialization.c:24 > #16 0x4008c6d5 in Java_java_lang_VirtualMachine_invokeMain (_env=3D0x80= 4d548,=20 > _class=3D0x805fda8, mainClass=3D0x805fdb8, args=3D0x805fdc8) > 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 nativ= e.c:834 > #20 0x40071aa4 in _svmf_interpreter (_env=3D0x804d548) > at instructions_switch.c:9791 > #21 0x40057a60 in CallStaticVoidMethod (_env=3D0x804d548, cls=3D0x805f1= 98,=20 > methodID=3D0x41250818) at native_interface.c:14894 > #22 0x0804aa4d in main (argc=3D2, argv=3D0xbffff8e4) at sablevm.c:1434 > (gdb)=20 >=20 >=20 > -----------------------------------------------------------------------= - >=20 >=20 > public class Hello { >=20 > static { > System.loadLibrary("hello"); > } >=20 > private static native void printHello(); >=20 >=20 > public static void main(String[] args) { > printHello(); > } >=20 > } >=20 >=20 > -----------------------------------------------------------------------= - >=20 > #include "Hello.h" >=20 > #include <stdio.h> >=20 > JNIEXPORT void JNICALL Java_Hello_printHello > (JNIEnv *env, jclass c) { > printf("Hello!\n"); > } >=20 >=20 >=20 > -----------------------------------------------------------------------= - >=20 > /* DO NOT EDIT THIS FILE - it is machine generated */ > #include <jni.h> > /* Header for class Hello */ >=20 > #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); >=20 > #ifdef __cplusplus > } > #endif > #endif >=20 >=20 > -----------------------------------------------------------------------= - >=20 > 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/ |