bug-guile-ncurses
[Top][All Lists]
Advanced

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

Re: [Bug-guile-ncurses] [PATCH 1/2] Add reference count to ITEM structs


From: John Darrington
Subject: Re: [Bug-guile-ncurses] [PATCH 1/2] Add reference count to ITEM structs contained by SCMs
Date: Tue, 3 May 2016 18:33:36 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

On Tue, May 03, 2016 at 02:11:56PM +0000, Mike Gran wrote:
     
     
     
     > On Tuesday, May 3, 2016 5:20 AM, John Darrington <address@hidden> wrote:
     > > This patch (partially) fixes a bug where a segmentation violation in 
the 
     > guile library would occur after, for example the current-item had been 
called.
     > 
     > The problem was, the native C item struct is shared between many SCM 
smobs.
     > Thus, if the garbage collector is allowed to run on any one of them, 
it'll
     > free memory which will later be needed by another.
     > 
     > This patch fixes the problem by using the "userptr" member as a 
     > reference count.
     
     Not too excited about this idea, but, it is better that the present
     condition.

I thought a bit about this.  The only other reasonable solution I could think of
was to keep a hash table.  But that seemed like a lot of effort.   It does mean 
that one cannot use the userptr for any other purpose, but that kind of paradigm
doesn't fit into the scheme way of doing things anyway.

I wasn't too happy about having to cast from pointer to integer and back again.

     
     I'll push after I've written a test case for the test suite.

Writing a reproducible test case is hard because the GC being a conservative
one, one can't force it to do anyting.  But perhaps you're better at it
than I am.
     
J'

-- 
Avoid eavesdropping.  Send strong encryted email.
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.net or any PGP keyserver for public key.

Attachment: signature.asc
Description: Digital signature


reply via email to

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