This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
RE: valgrind and CNI
- From: "Boehm, Hans" <hans dot boehm at hp dot com>
- To: "David Blasby" <dblasby at gmail dot com>, <java at gcc dot gnu dot org>
- Date: Sun, 13 Feb 2005 12:20:15 -0800
- Subject: RE: valgrind and CNI
I don't know about the hanging problem. The error messages about the
GC are well understood and expected. See also
http://article.gmane.org/gmane.comp.programming.garbage-collection.boehm
gc/733
Hans
> -----Original Message-----
> From: java-owner@gcc.gnu.org [mailto:java-owner@gcc.gnu.org]
> On Behalf Of David Blasby
> Sent: Sunday, February 13, 2005 10:03 AM
> To: java@gcc.gnu.org
> Subject: valgrind and CNI
>
>
> I wrote a C++ wrapper (using CNI) around a Java library, and
> a "C" program that calls the C++ wrapper. It appears to work
> fine, but when I try to valgrind it, valgrind complains a bit
> then hangs (at 100%) cpu.
>
> I simplified my program so that I have a simple C++ program
> that calls the Java library (using CNI). When I valgrind, I
> find that it does the same thing - spits out a few errors then hangs.
>
> Is this a known problem or is there something wrong with my program?
>
> [dblasby@localhost ~/jts_compile]$ valgrind --tool=memcheck
> a.out ==3571== Memcheck, a memory error detector for
> x86-linux. ==3571== Copyright (C) 2002-2004, and GNU GPL'd,
> by Julian Seward et al. ==3571== Using valgrind-2.2.0, a
> program supervision framework for x86-linux. ==3571==
> Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward et
> al. ==3571== For more details, rerun with: -v ==3571==
> ==3571== Conditional jump or move depends on uninitialised value(s)
> ==3571== at 0x6C6E916: GC_push_all_eager (in
> /usr/lib/libgcj.so.5.0.0)
> ==3571== by 0x6C6FD0B: GC_push_current_stack (in
> /usr/lib/libgcj.so.5.0.0)
> ==3571== by 0x6C75F86: GC_generic_push_regs (in
> /usr/lib/libgcj.so.5.0.0)
> ==3571== by 0x6C6FE17: GC_push_roots (in /usr/lib/libgcj.so.5.0.0)
> ==3571==
> ==3571== Conditional jump or move depends on uninitialised value(s)
> ==3571== at 0x6C6E916: GC_push_all_eager (in
> /usr/lib/libgcj.so.5.0.0)
> ==3571== by 0x6C6E975: GC_push_all_stack (in
> /usr/lib/libgcj.so.5.0.0)
> ==3571== by 0x6C75A32: GC_push_all_stacks (in
> /usr/lib/libgcj.so.5.0.0)
> ==3571== by 0x6C71B0B: GC_default_push_other_roots (in
> /usr/lib/libgcj.so.5.0.0)
> ==3571==
> ==3571== Syscall param sigaction(act) contains uninitialised
> or unaddressable byte(s)
> ==3571== at 0x735A77: syscall (in /lib/tls/libc-2.3.3.so)
> ==3571== Address 0x52BFE730 is on thread 1's stack
> ==3571== Conditional jump or move depends on uninitialised value(s)
> ==3571== at 0x6C751ED: GC_pthread_create (in
> /usr/lib/libgcj.so.5.0.0)
> ==3571== by 0x6AAEB55: _Jv_ThreadStart(java::lang::Thread*,
> _Jv_Thread_t*, void (*)(java::lang::Thread*)) (in
> /usr/lib/libgcj.so.5.0.0)
> ==3571== by 0x6ADA438: java::lang::Thread::start() (in
> /usr/lib/libgcj.so.5.0.0)
> ==3571== by 0x6AB0858: _Jv_CreateJavaVM(void*) (in
> /usr/lib/libgcj.so.5.0.0)
> ==3571==
> ==3571== Thread 2:
> ==3571== Conditional jump or move depends on uninitialised value(s)
> ==3571== at 0x1BA5C765: thread_wrapper (vg_libpthread.c:836)
> ==3571== by 0xB000F14F: do__quit (vg_scheduler.c:1872)
> ==3571==
> ==3571== Thread 2:
> ==3571== thread_wrapper: invalid attr->__detachstate
> ==3571== at 0x1BA5B8A0: pthread_error (vg_libpthread.c:380)
> ==3571== by 0x1BA5C772: thread_wrapper (vg_libpthread.c:838)
> ==3571== by 0xB000F14F: do__quit (vg_scheduler.c:1872)
> ==3571==
> ==3571== Thread 2:
> ==3571== Conditional jump or move depends on uninitialised value(s)
> ==3571== at 0x1BA5C779: thread_wrapper (vg_libpthread.c:839)
> ==3571== by 0xB000F14F: do__quit (vg_scheduler.c:1872)
>
> (hangs)
>
> Here's the C++ program:
>
> #pragma GCC java_exceptions
>
> #include "Geometry.h"
> #include "StaticGeometry.h"
> #include <java/lang/Integer.h>
> #include <java/lang/Math.h>
> #include <gcj/cni.h>
> #include <stdio.h>
> #include <java/lang/System.h>
> #include <java/lang/String.h>
> #include <java/io/PrintStream.h>
> #include <java/lang/Throwable.h>
>
> int main(int argc, char** argv)
> {
> // using namespace java::lang::String;
> using namespace java::lang;
> using namespace com::vividsolutions::jts::geom;
> using namespace test;
>
>
>
> JvCreateJavaVM(NULL);
> JvAttachCurrentThread(NULL, NULL);
>
> JvInitClass(&java::lang::System::class$);
> JvInitClass(&Geometry::class$);
> JvInitClass(&StaticGeometry::class$);
> JvInitClass(&System::class$);
> JvInitClass(&String::class$);
>
>
> char *wkt1 = "LINESTRING(-10 -10,20 20)";
>
> jstring wkt_j = JvNewStringLatin1 (wkt1);
> printf("about to call java function geomFromWKT\n");
> Geometry *g1 =StaticGeometry::geomFromWKT(wkt_j);
> printf("about to call java function getLength\n");
> jdouble len1 = StaticGeometry::getLength(g1);
>
> printf("len1 = %g\n", (double) len1);
> }
> // gcjh Geometry
> //
> // gcj -g -shared -o libjts.so jts-1.5.jar
> // gcj -classpath jts-1.5.jar -shared -o libstaticgeom.so
> StaticGeometry.class
>
> //g++ -g t.cc -lgcj -ljts -lstaticgeom -L.
> // /sbin/ldconfig ~dblasby/helloworld/
>
> Thanks,
>
> dave
>