valgrind and CNI

David Blasby dblasby@gmail.com
Mon Feb 14 17:48:00 GMT 2005


Thanks for the quick reply.
I'm using:
valgrind-2.2.0
gcj (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)
I was originally using valgrind to make sure that GCJ wasnt garbage
collecting my Java objects when I passed them from C++ to C. For
example, I use Geometry.h (created using gcjh) in the C++ library, but
a "typedef struct Geometry Geometry;" in the "C" program.
Java creates an Object, hands it off to the C++ library as a Geometry*
class, then gets passed as a pointer to the "C" program. I thought
the garbage collector might collect the java object between the time
it leaves the C++ library and arrives at the "C" program.
I've tried to get my "C" program to leak java objects, but the garbage
collector seems to be doing its job. I just wanted to make sure it
wasnt deleting too aggressively.
Is this going to cause any problems?
Thanks,
dave
On 2005年2月13日 12:20:15 -0800, Boehm, Hans <hans.boehm@hp.com> wrote:
> 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
> >
>


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /