Newbie question about Alien interface in CMUCL 
Author Message
 Newbie question about Alien interface in CMUCL

Hi,
  I am interested in using LISP for an analysis routine that I am writting.
I normally use a package called ROOT (used in the High Energy Physics
community and written in C++) to store and read my data. I am trying to
read each event, and then do my analysis. To read the events I have made
some small wrapper functions in C which initializes ROOT and another which
will read any event. the event record is being passed from ROOT to LISP
using 3 globally declared structures. So my code looks like:

struct foo_ {
.......

Quote:
} foo;

foo *  root_init() {
.....;
return &foo;

Quote:
}

void getentry(int i) {
.......

Quote:
}

*******************************************************************

(def-alien-type nil
   (struct foo
.......)))

(def-alien-routine root_init
.....)))
(def-alien-routine getentry
.....)))

(defun startprocessing ()
  (root_init)
  (dotime (j 500)
     (getentry j)))

the program works flawlessly till the second garbage collection, at which
point it gives an error like:

 *** Break *** segmentation violation

Error in function UNIX::SIGABRT-HANDLER:  SIGABRT at #x4007C801.

This error always happens during garbage collection. I have used (ext:gc)
twice and seen it to crash during the second time. ROOT malloc's lots of
buffers and other stuff internally. It is not possible for me to declare
all the buffers and stuff as def-alien-variable in LISP.

My question is: During garbage collection, does LISP overwrite globally
declared variables in the foreign library that I am loading for the ROOT
code?

Thanx in advance for any help.

 Cheers,
   Diptansu



Sat, 11 Jun 2005 00:41:23 GMT  
 Newbie question about Alien interface in CMUCL

  dd> Error in function UNIX::SIGABRT-HANDLER:  SIGABRT at #x4007C801.
  dd>
  dd> This error always happens during garbage collection. I have used
  dd> (ext:gc) twice and seen it to crash during the second time. ROOT
  dd> malloc's lots of buffers and other stuff internally. It is not
  dd> possible for me to declare all the buffers and stuff as
  dd> def-alien-variable in LISP.
  dd>
  dd> My question is: During garbage collection, does LISP overwrite
  dd> globally declared variables in the foreign library that I am
  dd> loading for the ROOT code?

your question is very specific to the CMUCL implementation; you may
obtain more useful responses to questions of this nature on the
cmucl-help mailing list (see <URL:http://www.cons.org/cmucl/support.html>).

CMUCL partitions the address space available to it on startup, and
reserves most of the available space for the lisp heap. Only 128MB or
256MB (depending on the platform) is available to memory allocated
from foreign code via the brk() system call, for example stuff that is
allocated with malloc() from C code, or via the MAKE-ALIEN function in
CMUCL, which allocates in foreign space.

It is possible that your problem is due to allocating more than this
amount from foreign code. The only solution that I see is to rebuild
CMUCL with a modified memory map that allocates more space to foreign
allocation. There is a description of how to do so on the CMUCL web
site (be warned that building CMUCL is not a trivial undertaking).

--
Eric Marsden                          <URL:http://www.laas.fr/~emarsden/>



Fri, 17 Jun 2005 23:23:42 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. cmucl alien type question

2. ALIEN objects and GC in CMUCL

3. CMUCL, def-alien-routine, c-string type and :in-out behaviour

4. CMUCL ALIEN PROBLEM

5. NEWBIE cmucl debugger question

6. newbie question: back history on the CMUCL listener

7. Newbie question: How to set a default pathname for cmucl as Emacs inferior-lisp

8. newbie question: implementation inheritance and interface specifications in Haskell 98

9. Another Newbie question about interfacing to C

10. Newbie question about interface to C

11. Newbie question: XT keyboard interface

12. newbie-question: interfaces

 

 
Powered by phpBB® Forum Software