Thread: [Sablevm-developer] native libs
Brought to you by:
egagnon
From: David P. B. <db...@CS...> - 2003-01-20 19:14:48
|
Hi, I'm getting a segmentation fault when trying to load a native library. The system native library (libjava-lang, libjava-io) get properly loaded 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). 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 |
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/ |
From: David P. B. <db...@CS...> - 2003-01-20 21:49:34
|
I have the same problem on both Debian/PPC and Debian/x86. However, the x86 version is the older 1.0.1 version installed in the sable lab. The P= PC version is based on 1.0.5 with my PPC patch. I will try on 1.0.5 on x= 86 tonight. David On Mon, Jan 20, 2003 at 04:21:01PM -0500, Prof. Etienne M. Gagnon wrote: > OK. I'm back! :-) >=20 > I'll look at this tomorrow. You're on Debian/x86, right? >=20 > Etienne >=20 > 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:24= 6 > >#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 > --=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 > ------------------------------------------------------- > This SF.NET email is sponsored by: FREE SSL Guide from Thawte > are you planning your Web Server Security? Click here to get a FREE > Thawte SSL guide and find the answers to all your SSL security issues. > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en > _______________________________________________ > Sablevm-developer mailing list > Sab...@li... > https://lists.sourceforge.net/lists/listinfo/sablevm-developer --=20 --- 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 |
From: David P. B. <db...@CS...> - 2003-01-21 14:34:35
|
Just to let you know that I have the same problem with version 1.0.5 on x86. David On Mon, Jan 20, 2003 at 04:49:30PM -0500, David Paul BELANGER wrote: >=20 > I have the same problem on both Debian/PPC and Debian/x86. However, th= e > x86 version is the older 1.0.1 version installed in the sable lab. The= PPC version is based on 1.0.5 with my PPC patch. I will try on 1.0.5 on= x86 tonight. >=20 >=20 > David >=20 > On Mon, Jan 20, 2003 at 04:21:01PM -0500, Prof. Etienne M. Gagnon wrote= : > > OK. I'm back! :-) > >=20 > > I'll look at this tomorrow. You're on Debian/x86, right? > >=20 > > Etienne > >=20 > > David Paul BELANGER wrote: > > >Hi, > > > > > >I'm getting a segmentation fault when trying to load a native librar= y. > > >The system native library (libjava-lang, libjava-io) get properly lo= aded > > >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). > > > > > >I have included some gdb output and a simple Hello program that caus= e > > >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=3D0= x80636b8,=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=3D0x804d54= 8,=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=3D0x804d5= 48,=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:= 352 > > >#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=3D= 0x805fdc8) > > > 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=3D0x80= 5f198,=20 > > > methodID=3D0x41250818) at native_interface.c:14894 > > >#22 0x0804aa4d in main (argc=3D2, argv=3D0xbffff8e4) at sablevm.c:14= 34 > > >(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 > > --=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 > > ------------------------------------------------------- > > This SF.NET email is sponsored by: FREE SSL Guide from Thawte > > are you planning your Web Server Security? Click here to get a FREE > > Thawte SSL guide and find the answers to all your SSL security issue= s. > > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en > > _______________________________________________ > > Sablevm-developer mailing list > > Sab...@li... > > https://lists.sourceforge.net/lists/listinfo/sablevm-developer >=20 > --=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 --- 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 |
From: David P. B. <db...@CS...> - 2003-01-22 03:18:27
|
I was able to fix it. I was confused for quite some time by a pointer getting "magically" the value NULL. From my understanding there is a bootstrap class loader and "application" class loader(s). The native library list in the applicatio= n 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. I will clean up my code and send a patch via the bug tack system. David On Mon, Jan 20, 2003 at 04:21:01PM -0500, Prof. Etienne M. Gagnon wrote: > OK. I'm back! :-) >=20 > I'll look at this tomorrow. You're on Debian/x86, right? >=20 > Etienne >=20 > 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:24= 6 > >#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 > --=20 > Etienne M. Gagnon, Ph.D. http://www.info.uqam.ca/~egagnon/ > SableVM: http://www.sablevm.org/ > SableCC: http://www.sablecc.org/ --=20 --- 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 |
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/ |