This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

CNI Segfault


Hello,

I'm using gcj from gcc 3.3.2(20031218) on compiled with CFLAGS
-O3 -march=pentium4 -pipe -fomit-frame-pointer 

Whilst simple java classes work I'm getting a segmentation fault when I try to 
use CNI to call java from C++. For example

#include <iostream>
#include <string>
#include <gcj/cni.h>
#include <java/lang/System.h>
#include <java/io/PrintStream.h>

using namespace std;

main( int argc, char **argv ){
    string s;
    cin >> s;
    jstring jstr = JvNewStringUTF(s.c_str());
    java::lang::System::out->println(jstr);
}

compiled with 
g++ mytest2.cpp -lgcj -ggdb

and run in gdb segfaults with:

(gdb) step
JvNewStringUTF (bytes=0x804a1b4 "Hello") at cni.h:95
95        return _Jv_NewStringUTF (bytes);
(gdb) step

Program received signal SIGSEGV, Segmentation fault.
0x40398d82 in _Jv_equalUtf8Consts(_Jv_Utf8Const*, _Jv_Utf8Const*) ()
   from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libgcj.so.4

I get similar problems with other test code.

Hope I'm not missing something stupidly obvious. Any help would be greatly 
appreciated!

Cheers,

Daniel.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]