From patchwork Tue Feb 10 14:45:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Wingo X-Patchwork-Id: 5021 Received: (qmail 26791 invoked by alias); 10 Feb 2015 14:45:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 26771 invoked by uid 89); 10 Feb 2015 14:45:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_NEUTRAL autolearn=ham version=3.3.2 X-HELO: sasl.smtp.pobox.com Received: from pb-sasl1.int.icgroup.com (HELO sasl.smtp.pobox.com) (208.72.237.25) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Feb 2015 14:45:41 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id 53B0C34BCA; Tue, 10 Feb 2015 09:45:39 -0500 (EST) Received: from pb-sasl1.int.icgroup.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id 4037C34BC6; Tue, 10 Feb 2015 09:45:39 -0500 (EST) Received: from rusty (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl1.pobox.com (Postfix) with ESMTPSA id 4C59334BC1; Tue, 10 Feb 2015 09:45:36 -0500 (EST) From: Andy Wingo To: Doug Evans Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] [guile] Run finalizers from GDB thread References: <87sipcqdmo.fsf@igalia.com> Date: Tue, 10 Feb 2015 15:45:34 +0100 In-Reply-To: (Doug Evans's message of "Sat, 26 Apr 2014 13:26:14 -0700") Message-ID: <878ug5965t.fsf@igalia.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 X-Pobox-Relay-ID: 7A7C8B12-B133-11E4-A1D4-DC3B3EDD908B-02397024!pb-sasl1.pobox.com Hi :) On Sat 26 Apr 2014 22:26, Doug Evans writes: > Andy Wingo writes: > >> gdb/ChangeLog: >> * guile/guile.c (_initialize_guile): Disable automatic >> finalization, if Guile offers us that possibility. >> >> * guile/guile.c (call_initialize_gdb_module): >> * guile/scm-safe-call.c (gdbscm_with_catch): Arrange to run >> finalizers in appropriate places. >> >> * configure.ac: Add a check for >> scm_set_automatic_finalization_enabled. > > Hi. Ok with a few nits. > > 1) Since all of these changes are related, don't separate them with > blank lines in the changelog entry. > > 2) Write the configure.ac entry as: > * configure.ac (AC_TRY_LIBGUILE): Add a check for > scm_set_automatic_finalization_enabled. > > 3) Include the changelog entry for configure being regenerated, even > though it's not included in the patch: > * configure: Regenerate. Updated patch to fix nits. Cheers! Andy From 4a9919c3e731f0210cfbcfbbb6040189f46a7fbb Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Tue, 10 Feb 2015 15:26:24 +0100 Subject: [PATCH] [guile] Run finalizers from GDB thread gdb/ChangeLog: * guile/guile.c (_initialize_guile): Disable automatic finalization, if Guile offers us that possibility. * guile/guile.c (call_initialize_gdb_module): * guile/scm-safe-call.c (gdbscm_with_catch): Arrange to run finalizers in appropriate places. * configure.ac (AC_TRY_LIBGUILE): Add a check for scm_set_automatic_finalization_enabled. * configure: Regenerated. --- gdb/ChangeLog | 11 +++++++++++ gdb/configure.ac | 5 +++++ gdb/guile/guile.c | 11 +++++++++++ gdb/guile/scm-safe-call.c | 4 ++++ 4 files changed, 31 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3e26864..0b7b4b7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,14 @@ +2015-02-10 Andy Wingo + + * guile/guile.c (_initialize_guile): Disable automatic + finalization, if Guile offers us that possibility. + * guile/guile.c (call_initialize_gdb_module): + * guile/scm-safe-call.c (gdbscm_with_catch): Arrange to run + finalizers in appropriate places. + * configure.ac (AC_TRY_LIBGUILE): Add a check for + scm_set_automatic_finalization_enabled. + * configure: Regenerated. + 2014-04-17 Andy Wingo * configure.ac: When Guile is available, check for the diff --git a/gdb/configure.ac b/gdb/configure.ac index 886e83b..3e96016 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -1085,6 +1085,11 @@ AC_DEFUN([AC_TRY_LIBGUILE], GUILE_CPPFLAGS=$new_CPPFLAGS GUILE_LIBS=$new_LIBS], [found_usable_guile=no]) + dnl scm_set_automatic_finalization_enabled added in Guile 2.2. + AC_CHECK_FUNC(scm_set_automatic_finalization_enabled, + AC_DEFINE(HAVE_GUILE_MANUAL_FINALIZATION, 1, + [Define if Guile supports manual finalization.]) + ) CPPFLAGS=$save_CPPFLAGS LIBS=$save_LIBS if test "${found_usable_guile}" = no; then diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c index 319b583..e9d2aae 100644 --- a/gdb/guile/guile.c +++ b/gdb/guile/guile.c @@ -698,6 +698,10 @@ call_initialize_gdb_module (void *data) performed within the desired module. */ scm_c_define_module (gdbscm_module_name, initialize_gdb_module, NULL); +#if HAVE_GUILE_MANUAL_FINALIZATION + scm_run_finalizers (); +#endif + return NULL; } @@ -844,6 +848,13 @@ _initialize_guile (void) side to define module "gdb" which imports "_gdb". There is evidently no similar convention in Guile so we skip this. */ +#if HAVE_GUILE_MANUAL_FINALIZATION + /* Our SMOB free functions are not thread-safe, as GDB itself is not + intended to be thread-safe. Disable automatic finalization so that + finalizers aren't run in other threads. */ + scm_set_automatic_finalization_enabled (0); +#endif + #ifdef HAVE_SIGPROCMASK /* Before we initialize Guile, block SIGCHLD. This is done so that all threads created during Guile initialization diff --git a/gdb/guile/scm-safe-call.c b/gdb/guile/scm-safe-call.c index 9255556..6052214 100644 --- a/gdb/guile/scm-safe-call.c +++ b/gdb/guile/scm-safe-call.c @@ -155,6 +155,10 @@ gdbscm_with_catch (void *data) d->unwind_handler, d, d->pre_unwind_handler, d); +#if HAVE_GUILE_MANUAL_FINALIZATION + scm_run_finalizers (); +#endif + return NULL; } -- 2.1.4