From: ludo@gnu.org (Ludovic Courtès)
To: Doug Evans <xdje42@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 9/9] Remove a useless Guile finalizer
Date: Tue, 15 Apr 2014 09:29:00 -0000 [thread overview]
Message-ID: <87sipf9c17.fsf@gnu.org> (raw)
In-Reply-To: <m3ha5vsia3.fsf@sspiff.org> (Doug Evans's message of "Mon, 14 Apr 2014 14:39:00 -0700")
Doug Evans <xdje42@gmail.com> skribis:
> ludo@gnu.org (Ludovic Courtès) writes:
>
>> Doug Evans <xdje42@gmail.com> skribis:
>>
>>> Andy Wingo <wingo@igalia.com> writes:
>>>
>>>> * gdb/guile/scm-symtab.c (stscm_free_sal_smob): Remove useless free
>>>> function. (This was the only useless free function.)
>>>> ---
>>>> gdb/guile/scm-symtab.c | 14 --------------
>>>> 1 file changed, 14 deletions(-)
>>>>
>>>> diff --git a/gdb/guile/scm-symtab.c b/gdb/guile/scm-symtab.c
>>>> index 8910973..876bf64 100644
>>>> --- a/gdb/guile/scm-symtab.c
>>>> +++ b/gdb/guile/scm-symtab.c
>>>> @@ -386,19 +386,6 @@ gdbscm_symtab_static_block (SCM self)
>>>> \f
>>>> /* Administrivia for sal (symtab-and-line) smobs. */
>>>>
>>>> -/* The smob "free" function for <gdb:sal>. */
>>>> -
>>>> -static size_t
>>>> -stscm_free_sal_smob (SCM self)
>>>> -{
>>>> - sal_smob *s_smob = (sal_smob *) SCM_SMOB_DATA (self);
>>>> -
>>>> - /* Not necessary, done to catch bugs. */
>>>> - s_smob->symtab_scm = SCM_UNDEFINED;
>>>> -
>>>> - return 0;
>>>> -}
>>>> -
>>>> /* The smob "print" function for <gdb:sal>. */
>>>>
>>>> static int
>>>> @@ -692,7 +679,6 @@ gdbscm_initialize_symtabs (void)
>>>> scm_set_smob_print (symtab_smob_tag, stscm_print_symtab_smob);
>>>>
>>>> sal_smob_tag = gdbscm_make_smob_type (sal_smob_name, sizeof (sal_smob));
>>>> - scm_set_smob_free (sal_smob_tag, stscm_free_sal_smob);
>>>> scm_set_smob_print (sal_smob_tag, stscm_print_sal_smob);
>>>>
>>>> gdbscm_define_functions (symtab_functions, 1);
>>>
>>> How useful is valgrind with Guile's GC?
>>
>> I think there’s a suppression file for libgc floating around, but I
>> haven’t really used it myself.
>>
>>> And given that we have this hook, it seems a shame to just throw out
>>> such useful protections against use-after-free (I'm pretty sure early on
>>> I found one bug with them), especially given the subtleties with GC,
>>> and gdb's extensive need to have references to SCM objects from outside
>>> GC-controlled code.
>>
>> IMO it doesn’t help much to have finalizers (free functions) like this.
>> For debugging, you could always use a guardian, which has the same effect.
>
> Ah. I probably didn't make myself clear. Sorry 'bout that.
> For smobs that are only ever accessed from Scheme then sure,
> no disagreement there.
>
> For smobs accessed from gdb ... that's the context in which my
> comments were made. Alas, any such object probably requires a free
> function anyway.
Why do you say it “requires” a free function? The comment says “Not
necessary, done to catch bugs.”
>>> If we're going to have a rule that such code is disallowed,
>>> there is more such code that needs to be removed besides the above
>>> (grep for "catch bugs").
>>>
>>> But is this something we want?
>>> At this stage in gdb+guile's development, I like the protection,
>>> and the cost is within epsilon of zero (to me anyway).
>>
>> Again, I don’t think it provides any significant protection or debugging
>> aid.
>
> I'm going to keep my NULL'ing out of smob elements in free functions
> (I see I'm missing a few), but only for such smobs that can be accessed
> from outside Scheme.
Can a ‘sal_smob’ be referred to by GDB objects once the corresponding
SMOB has been reclaimed? My impression is that the answer is “no.”
Thus I’m not sure what you mean by “accessed from outside Scheme.”
> It's an open question, I guess, whether modifying the smob like this in
> a finalizer could confuse gc.
No problem with that.
Thanks,
Ludo’.
next prev parent reply other threads:[~2014-04-15 9:29 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-09 16:14 [PATCH 0/8] Cleanups to Guile extension interface Andy Wingo
2014-04-09 16:14 ` [PATCH 2/9] Define and export Guile classes for all GDB object types Andy Wingo
2014-04-12 18:32 ` Doug Evans
2014-04-09 16:14 ` [PATCH 3/9] Fix excess parentheses in Guile extension examples Andy Wingo
2014-04-09 16:14 ` [PATCH 5/9] Rename "gsmob" in Guile interface to "gdb object" Andy Wingo
2014-04-12 18:46 ` Doug Evans
2014-04-17 9:39 ` Andy Wingo
2014-04-17 9:46 ` Eli Zaretskii
2014-04-09 16:14 ` [PATCH 6/9] Remove Guile GDB object property mechanism Andy Wingo
2014-04-12 19:23 ` Doug Evans
2014-04-17 9:54 ` Andy Wingo
2014-04-09 16:14 ` [PATCH 4/9] Fix typos in documentation of Guile `execute' function Andy Wingo
2014-04-09 16:14 ` [PATCH 7/9] Remove Guile mark functions that don't mark anything Andy Wingo
2014-04-12 19:29 ` Doug Evans
2014-04-17 9:48 ` Andy Wingo
2014-04-20 19:34 ` Doug Evans
2014-04-22 7:40 ` Andy Wingo
2014-04-29 11:51 ` Ludovic Courtès
2014-04-09 16:14 ` [PATCH 9/9] Remove a useless Guile finalizer Andy Wingo
2014-04-12 20:18 ` Doug Evans
2014-04-14 12:12 ` Ludovic Courtès
2014-04-14 21:39 ` Doug Evans
2014-04-15 9:29 ` Ludovic Courtès [this message]
2014-04-15 15:30 ` Doug Evans
2014-04-17 10:07 ` Andy Wingo
2014-04-09 16:14 ` [PATCH 8/9] Remove useless Guile SMOB marking functions Andy Wingo
2014-04-12 19:50 ` Doug Evans
2014-04-09 16:14 ` [PATCH 1/9] Allow GDB to build against unreleased Guile 2.2 Andy Wingo
2014-04-12 16:40 ` Doug Evans
2014-04-12 16:47 ` Doug Evans
2014-04-17 9:04 ` Andy Wingo
-- strict thread matches above, loose matches on Subject: below --
2014-04-09 16:09 [PATCH 0/8] Cleanups to Guile extension interface Andy Wingo
2014-04-09 16:09 ` [PATCH 9/9] Remove a useless Guile finalizer Andy Wingo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sipf9c17.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=xdje42@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox