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]

Re: Calling java code from C/C++ code.


Here's the result, with the patch, and GC_dump output.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 2811)]
0x405d8c13 in GC_mark_from_mark_stack () at ../../../gcc/boehm-gc/mark.c:584
584               deferred = *limit;
Current language:  auto; currently c
(gdb) p limit
$1 = (word *) 0x1f8
(gdb) p deferred
$2 = 1073884556
(gdb) ptype deferred
type = long unsigned int
(gdb) p GC_dump()
***Static roots:
>From 0x0 to 0x804a260
>From 0x40022d8c to 0x40022f34  (temporary)
>From 0x4007c7e0 to 0x4008a1e8  (temporary)
>From 0x400a9820 to 0x400a99b8  (temporary)
>From 0x400b4054 to 0x400b4630  (temporary)
>From 0x401ce6e0 to 0x401d6cc8  (temporary)
>From 0x40015ba0 to 0x4001627c  (temporary)
>From 0x4001ebc0 to 0x4001f3ac  (temporary)
>From 0x404c2300 to 0x405cab0c  (temporary)
>From 0x405e2940 to 0x405eb340  (temporary)
>From 0x40604200 to 0x4060af5c  (temporary)
>From 0x4061b6a0 to 0x4061cb48  (temporary)
Total size: 135769668

***Heap sections:
Total heap size: 65536
Section 0 from 0x8063000 to 0x8073000 1/16 blacklisted

***Free blocks:
Free list 16:
        0x8063000 size 65536 not black listed
Total of 65536 bytes on free list

***Blocks in use:
(kind(0=ptrfree,1=normal,2=unc.,3=stubborn):size_in_bytes, #_marks_set)

blocks = 0, bytes = 0
$3 = void

(gdb) where

#0  0x405d8c13 in GC_mark_from_mark_stack ()
    at ../../../gcc/boehm-gc/mark.c:584
#1  0x405d85d7 in GC_mark_some (
    cold_gc_frame=0xbffff634
" *]@<-^@\\öÿ¿\001)]@ $]@<-^@\\öÿ¿ê(]@P(]@<-^@\214öÿ¿\200´]@ $]@<-^@\214öÿ¿r´]@?öÿ¿àÏ")
at ../../../gcc/boehm-gc/mark.c:315
#2  0x405d2b0c in GC_stopped_mark (stop_func=0x405d24a0 <GC_never_stop_func>)
    at ../../../gcc/boehm-gc/alloc.c:445
#3  0x405d2901 in GC_try_to_collect_inner (
    stop_func=0x405d24a0 <GC_never_stop_func>)
    at ../../../gcc/boehm-gc/alloc.c:324
#4  0x405db480 in GC_init_inner () at ../../../gcc/boehm-gc/misc.c:561
#5  0x405d741f in GC_generic_malloc_inner (lb=10, k=0)
    at ../../../gcc/boehm-gc/malloc.c:61
#6  0x405d75d5 in GC_generic_malloc (lb=10, k=0)
    at ../../../gcc/boehm-gc/malloc.c:133
#7  0x405d7674 in GC_malloc_atomic (lb=10)
    at ../../../gcc/boehm-gc/malloc.c:172
#8  0x4045ca8d in _Z14_Jv_AllocBytesi (size=10)
    at ../../../gcc/libjava/boehm.cc:375
#9  0x403260b7 in _Z17_Jv_makeUtf8ConstPci (s=0x40467398 "()V", len=3)
    at ../../../gcc/libjava/prims.cc:252
#10 0x4034048a in __static_initialization_and_destruction_0 (__initialize_p=1,
    __priority=65535) at ../../../gcc/libjava/java/lang/natClass.cc:70
#11 0x403404b2 in global constructors keyed to
_ZN4java4lang5Class7forNameEPNS0_6StringEPNS0_11ClassLoaderE ()
    at ../../../gcc/libjava/java/lang/natClass.cc:316
#12 0x404605c7 in __do_global_ctors_aux ()
    at ../../../../gcc/libstdc++-v3/libsupc++/vec.cc:59
#13 0x4031cc2e in _init ()
   from /nfs/dev-users/twall/install-fsf/lib/libgcj.so.1
#14 0x4000d549 in _dl_init (main_map=0x8050b18, argc=1, argv=0xbffffc04,
    env=0xbffffc0c) at dl-init.c:112
#15 0x401ba38a in dl_open_worker (a=0xbffff9f0) at dl-open.c:325
#16 0x4000d2e5 in _dl_catch_error (objname=0xbffff9e8, errstring=0xbffff9ec,
    operate=0x401ba0bc <dl_open_worker>, args=0xbffff9f0) at dl-error.c:149
#17 0x401ba606 in _dl_open (file=0x8048e34 "./test.so", mode=-2147483647,
    caller=0x8048a65) at dl-open.c:380
#18 0x400213bf in dlopen_doit (a=0xbffffb50) at dlopen.c:39
#19 0x4000d2e5 in _dl_catch_error (objname=0x40022f24, errstring=0x40022f28,
    operate=0x40021394 <dlopen_doit>, args=0xbffffb50) at dl-error.c:149
#20 0x40021712 in _dlerror_run (operate=0x40021394 <dlopen_doit>,
    args=0xbffffb50) at dlerror.c:130
#21 0x4002137f in __dlopen_check (file=0x8048e34 "./test.so", mode=1)
    at dlopen.c:53
#22 0x8048a65 in main (argc=1, argv=0xbffffc04) at loader.cc:10
#23 0x400d1b5c in __libc_start_main (main=0x8048a50 <main>, argc=1,
    ubp_av=0xbffffc04, init=0x804881c <_init>, fini=0x8048e0c <_fini>,
    rtld_fini=0x4000d634 <_dl_fini>, stack_end=0xbffffbfc)
    at ../sysdeps/generic/libc-start.c:129


Bryce McKinlay wrote:

> Timothy Wall wrote:
>
> > I tried the patch but apparently it didn't apply cleanly to Class.h.  Can you
> > post  the correct Class constructors?
>
> With the patch, there is only one C++ constructor for class:
>
>   Class ()
>   {
>      // C++ ctors set the vtbl pointer to point at an offset inside the vtable
>      // object. That doesn't work for Java, so this hack adjusts it back.
>      void *p =  ((void **)this)[0];
>      ((void **)this)[0] = (void *)((char *)p-2*sizeof (void *));
>   };
>
> (reading the patch may be confusing because the other one is commented out
> instead of removed. sorry about that)
>
> regards
>
>   [ bryce ]


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