unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Alternative to scm_protects?
@ 2014-06-30  3:13 Devon Schudy
  2014-07-01  9:54 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Devon Schudy @ 2014-06-30  3:13 UTC (permalink / raw)
  To: guile-user

scm_protects is no longer public in Guile 2.1. AFAICT there's no other
way to find out what objects are protected. Should there be?

Lilypond uses scm_protects as a tool for debugging memory leaks
(especially ones due to forgetting to unprotect). This isn't an
important feature, so it can just be disabled when not available. But
other users of the C interface are likely to have leaks and want a way
to debug them, so it might be worth supporting.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Alternative to scm_protects?
  2014-06-30  3:13 Alternative to scm_protects? Devon Schudy
@ 2014-07-01  9:54 ` Ludovic Courtès
  2014-07-03 15:08   ` Devon Schudy
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2014-07-01  9:54 UTC (permalink / raw)
  To: Devon Schudy; +Cc: guile-user

Since Guile 2.0, which switched to BDW-GC, scm_protects has been mostly
irrelevant because BDW-GC scans all the C global variables.

Actually, libguile/gc.c in 2.0 reads this:

--8<---------------cut here---------------start------------->8---
#if SCM_ENABLE_DEPRECATED == 1
/* Hash table that keeps a reference to objects the user wants to protect from
   garbage collection.  It could arguably be private but applications have come
   to rely on it (e.g., Lilypond 2.13.9).  */
SCM scm_protects;
#else
static SCM scm_protects;
#endif
--8<---------------cut here---------------end--------------->8---

So the alternative to scm_protects should be just something like this:

  static SCM my_protects;

    ...
    my_protects = scm_cons (obj, my_protects); /* or a hash table */

Would it work for LilyPond?

Ludo’.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Alternative to scm_protects?
  2014-07-01  9:54 ` Ludovic Courtès
@ 2014-07-03 15:08   ` Devon Schudy
  0 siblings, 0 replies; 3+ messages in thread
From: Devon Schudy @ 2014-07-03 15:08 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guile-user

Ludovic Courtès wrote:
> Since Guile 2.0, which switched to BDW-GC, scm_protects has been mostly
> irrelevant because BDW-GC scans all the C global variables.

Oh, it's irrelevant because users can easily implement it themselves —
it's just a convenience now.

So at worst, Lilypond can simply reimplement protects, which is <1 page. Thanks.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-07-03 15:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-30  3:13 Alternative to scm_protects? Devon Schudy
2014-07-01  9:54 ` Ludovic Courtès
2014-07-03 15:08   ` Devon Schudy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).