guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Several questions.


From: Dirk Herrmann
Subject: Re: Several questions.
Date: Fri, 20 Apr 2001 19:39:27 +0200 (MEST)

On 20 Apr 2001, Marius Vollmer wrote:

> > * scm_smobs is a malloc'd array that gets resized for every new
> >   smob.  With preemptive threading, this will not work well:  It would be
> >   necessary to guard every access to scm_smobs with a mutex.
> 
> Does pthreads offer something like a atomic update for a pointer?
> With such a thing, we could atomically swap in the new smobtable.

I don't think so.  The problem does not depend on whether the pointer can
be updated atomically.  Assume thread A wants to print some smob
object.  Thus, it has just read the value of scm_smobs, pointing to some
memory region.  Exactly in this moment, thread B is activated.  B installs
a new smob type, which means:  The old memory region gets freed due to the
realloc.  scm_smobs is updated to point to the new memory region.  Now,
if control is returned to thread A, thread A will use the old value of
scm_smob to fetch the function pointer for printing the smob.  But,
since the old value of scm_smob now points into freed memory: *BOOM*

> 
> > * Building guile with  make "CFLAGS=-g -DSCM_DEBUG=1"  shows some
> >   inconsistent uses of DEFER/ALLOW ints.
> 
> Worse, it fails for me with
> 
>     $ guile
>     ints already disabled (at smob.c:288)
>     ERROR: Unbound variable: *top-level-lookup-closure*
> 
> I don't feel competent to look into this.  Anyone?

The problem comes from the fact that SCM_DEBUG=1 also makes sure that no
deprecated code is compiled into guile.  But, we don't have a possibility
yet to make sure that deprecated code is also taken out from the scheme
code.  Therefore, the problem that you have encountered indicates that
there is a scheme level reference to something that is deprecated on the C
level.  Unfortunately, the scheme reference cannot easily be removed
without breaking backwards compatibility.

You should rather use the following make command:
  make "CFLAGS=-g -DSCM_DEBUG_INTERRUPTS=1"
which will only enable the debugging of the interrupt stuff, but will
still leave all deprecated code in.  Sorry, I forgot that my local version
of guile is patched to avoid the "unbound *top-level-lookup-closure*"
problem.

Best regards,
Dirk Herrmann




reply via email to

[Prev in Thread] Current Thread [Next in Thread]