[Gc] Segmentation fault when embedding GC in Matlab (fwd)

Boehm, Hans hans.boehm at hp.com
Wed Aug 29 12:47:09 PDT 2007


 

> -----Original Message-----
> From: gc-bounces at napali.hpl.hp.com 
> [mailto:gc-bounces at napali.hpl.hp.com] On Behalf Of Goffioul Michael
> Sent: Thursday, August 23, 2007 1:23 AM
> To: Boehm, Hans; gc at napali.hpl.hp.com
> Subject: RE: [Gc] Segmentation fault when embedding GC in Matlab (fwd)
> 
> > It seems that GC_scratch_alloc (called by GC_init_headers) is 
> > returning null or a bogus pointer.  GC_scratch_alloc 
> usually gets its 
> > memory from either sbrk (default on your platform, I
> > think) or mmap (or it tries both in gc7).  It would be good to know 
> > what it's returning; I haven't seen this before.
> 
> I tracked down the problem a little bit further, with gdb.
> GC is using sbrk on my platform, around line 1639 in os_dep.c
> (GC_unix_get_mem):
> 
>     result = (ptr_t)sbrk((SBRK_ARG_T)bytes);
> 
> This call returns a correct address when matlab is started 
> without the JVM, and -1 (0xFFFFFFFF) when matlab is started 
> with the JVM.
That explains the problem.  The collector can't get any memory from the
OS, even during startup.  This might happen because in your environment
the JVM grabs the address space right above the sbrk heap, though I'm
not sure.

Things might work better if you build the collector with USE_MMAP
defined.  GC7 should largely avoid this problem by trying both under the
covers.
> 
> > Hopefully Matlab only invokes ECL from the main thread, not another 
> > JVM thread?  And cross-heap pointers are not an issue?
> 
> [don't know what you mean with cross-heap pointers] Regarding 
> JVM threads, my code doesn't do anything special with threads.
> I have a normal MEX file that I call from Matlab prompt. This 
> MEX file begins with calling cl_boot (from ECL), which in 
> turn initialize GC.
My concern is that the Java heap might contain pointers into the ECL
heap.  I don't know enough about Matlab to understand how the JVM is
being used here.

Hans
> 
> Michael.
> 
> _______________________________________________
> Gc mailing list
> Gc at linux.hpl.hp.com
> http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
> 



More information about the Gc mailing list