[Openmcl-devel] Elf symbols doesn't work on linuxx86-64.

Gary Byers gb at clozure.com
Mon Oct 13 21:32:44 PDT 2008



On Mon, 13 Oct 2008, David Brown wrote:

> On Mon, Oct 13, 2008 at 05:40:31AM -0600, Gary Byers wrote:
>
>> There seem to be a few different packages which provide incompatible
>> versions of libelf.  On a Fedora 9 system, I have
>
> That does seem to be the problem.  On gentoo, it looks like I need
> 'elfutils', instead of 'libelf'.  Only one of the packages can be
> compiled.
>
> Of course, that brings me to my Dead Mac Pointer bug when I try using
> saved images.  But, the elf thing seems to be working now.
>
> David
>
>

If you've described this (dead pointer) problem, I haven't seen the
message.  I don't think that this is documented (well) anywhere; sorry
if I'm repeating something that's in the manual.  (Actually, the manual
seems to mention the issue but doesn't say what to do about it.)

In general, a pointer (to some foreign address) is only meaningful
within a session; SAVE-APPLICATION walks memory, changing the type of
any non-NULL pointers it finds to DEAD-MACPTR.  Most operations on
pointers do typechecking, so attempting to access something leftover
from the previous session gets a type error (rather than acessing a foreign
address that's leftover from the previous session.)  The exception for
NULL pointers is somewhat arbitrary; it'd be just as reasonable to decide
that something pointing to a "small" address (for some value of "small")
isn't really a pointer "to" anything.

So:

(defvar *some-foreign-pointer* (#_malloc 1000))

(defun read-into-foreign-pointer (fd)
   (#_read fd *some-foreign-pointer* 1000))

(save-application "new-image")

...

;;; run the new image

...

(read-into-foreign-pointer some-fd)

will signal a TYPE-ERROR (because SAVE-APPLICATION has marked the value
of *some-foreign-pointer* as being dead.)

In a very simple case like this (where the pointer's only accessible
via a special variable), it's possible to use CCL:DEFLOADVAR:

(ccl:defloadvar *some-foreign-pointer* (#_malloc 1000))

That'll behave like DEFSTATIC (which -is- documented ...), but will
additionally push (a compiled version of) the initform on a list
of pointer-reinitialization functions that's run when an image
starts up.  Entries on this list are run in the order in which they're
defined, so:

(ccl:defloadvar *a* (something))

(ccl:defloadvar *b* (something-that-depends-on *a*))

will do the (re)initialization in the same order that the initialization
is done.

That's often adequate.  There are some other mechanisms (it's possible
to destructively change a DEAD-MACPTR back into a MACPTR in cases where
EQness matters, and it's possible to run arbitrary code at image startup
time.)





More information about the Openmcl-devel mailing list