From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Linas Vepstas Newsgroups: gmane.lisp.guile.user Subject: [PATCH 12/12] Guile-DBD-postgres: Crash in GC Date: Fri, 19 Sep 2008 09:23:33 -0500 Message-ID: <20080919142333.GL13684@linas.org> References: <3ae3aa420809190645o2fe2b746id80f53c5cb123e5b@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="E6lVPAHcXg6biC3t" X-Trace: ger.gmane.org 1221834502 10041 80.91.229.12 (19 Sep 2008 14:28:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 19 Sep 2008 14:28:22 +0000 (UTC) Cc: Guile User Mailing List To: Maurizio Boriani Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Sep 19 16:29:18 2008 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KggwY-0003bk-GG for guile-user@m.gmane.org; Fri, 19 Sep 2008 16:26:47 +0200 Original-Received: from localhost ([127.0.0.1]:35529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KggvW-0004Lq-Cr for guile-user@m.gmane.org; Fri, 19 Sep 2008 10:25:42 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kggtu-0003e4-Ld for guile-user@gnu.org; Fri, 19 Sep 2008 10:24:02 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kggtq-0003cg-OA for guile-user@gnu.org; Fri, 19 Sep 2008 10:24:02 -0400 Original-Received: from [199.232.76.173] (port=47016 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kggtq-0003cX-Cs for guile-user@gnu.org; Fri, 19 Sep 2008 10:23:58 -0400 Original-Received: from rv-out-0708.google.com ([209.85.198.247]:46195) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Kggtp-0008Nj-2U for guile-user@gnu.org; Fri, 19 Sep 2008 10:23:58 -0400 Original-Received: by rv-out-0708.google.com with SMTP id k29so503761rvb.6 for ; Fri, 19 Sep 2008 07:23:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :in-reply-to:user-agent:from; bh=YIqXVZ499WXKlKQpEdLsungscV6KKSArKcykZsmC+xc=; b=mCYGzoJyJn8VEMsJcO1f8wCjIFvxT0khnhjJqZ4EKMx+++HC6G/Qhdi28lXTfUy49W lBWi7q59CfylJkc7SGCc0dweHJpbTLVbaqXgnEH4EhKtiK2+XxSeHnjMArNacNMKPbJA xqV3n344S23zTo8sCoPuqL6W5mVKws8Y/+gOU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:to:cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent:from; b=Lqc8LR2bVK4azYZkR7dWhlIhLKkth5IHco/u3HM71UKlqgEORN1boQan44uC+NP7Ns iXtxtwjLgGDaSEFWKYbG2bd5Ia1T8B37ruefSiOdeGRULdyOyeVF9wwax9yJr9rxrwwJ NT+7Ps2QaU0LNS53yQgvkQ/QUeWMAUXD/lFIE= Original-Received: by 10.141.169.11 with SMTP id w11mr84661rvo.63.1221834230100; Fri, 19 Sep 2008 07:23:50 -0700 (PDT) Original-Received: from linas.org ( [67.100.217.179]) by mx.google.com with ESMTPS id 9sm1135265yxs.5.2008.09.19.07.23.44 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 19 Sep 2008 07:23:49 -0700 (PDT) Content-Disposition: inline In-Reply-To: <3ae3aa420809190645o2fe2b746id80f53c5cb123e5b@mail.gmail.com> User-Agent: Mutt/1.5.15+20070412 (2007-04-11) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:6795 Archived-At: --E6lVPAHcXg6biC3t Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Fix a serious bug which results in a crash in the GC. The problem is that the DBI free routine ill call the close routine, which will call this routine, which tries to alloc new SCM cells. But one must not alloc while the garbage collector is runing. Soo.. A previous patch added a flag to indicate that we're in the GC. If this flag is set, then avoid doing the cell allocs. Signed-off-by: Linas Vepstas --- src/guile-dbd-postgresql.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) Index: guile-dbd-postgresql-2.0.0/src/guile-dbd-postgresql.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- guile-dbd-postgresql-2.0.0.orig/src/guile-dbd-postgresql.c 2008-09-16 1= 9:57:34.000000000 -0500 +++ guile-dbd-postgresql-2.0.0/src/guile-dbd-postgresql.c 2008-09-16 20:05:= 25.000000000 -0500 @@ -181,6 +181,7 @@ __postgresql_close_g_db_handle(gdbi_db_h gdbi_pgsql_ds_t* pgsqlP =3D (gdbi_pgsql_ds_t*)dbh->db_info; =20 if (pgsqlP =3D=3D NULL) { + if (dbh->in_free) return; /* don't scm anything if in GC */ /* todo: error msg to be translated */ dbh->status =3D scm_cons(scm_from_int(1), scm_from_locale_string("dbd info not found")); @@ -188,9 +189,12 @@ __postgresql_close_g_db_handle(gdbi_db_h } else if (pgsqlP->pgsql =3D=3D NULL) { - /* todo: error msg to be translated */ - dbh->status =3D scm_cons(scm_from_int(1), - scm_from_locale_string("dbi connection already closed")); + if (0 =3D=3D dbh->in_free) + { + /* todo: error msg to be translated */ + dbh->status =3D scm_cons(scm_from_int(1), + scm_from_locale_string("dbi connection already closed")); + } free(dbh->db_info); dbh->db_info =3D NULL; dbh->closed =3D SCM_BOOL_T; @@ -207,8 +211,10 @@ __postgresql_close_g_db_handle(gdbi_db_h free(dbh->db_info); dbh->db_info =3D NULL; =20 - /* todo: error msg to be translated */ dbh->closed =3D SCM_BOOL_T; + + if (dbh->in_free) return; /* don't scm anything if in GC */ + /* todo: error msg to be translated */ dbh->status =3D scm_cons(scm_from_int(0), scm_from_locale_string("dbi closed")); return; --E6lVPAHcXg6biC3t Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iQEVAwUBSNO15YSDRXfAOJJBAQKvjQgAgW6nSUFLwzBxbptXGSqDYDCGg2mwpVCf ZdbjTnNgtkuwtfVThzsNO+8HMRAnGvaOpXmquZ/CBCJFhplF+jD2kH4+fLO79aP1 S6YigG5c7YVw18fKv1tGsTlDXuq9anpIq7Rd1uyO9Fy9dCVWBDK8dikJXEHAJ2dI FXidZBdUNKZCkI06LG9zQx6NPApN13aPOgVfwLv3oySPj9apt1a1N9zdKmmaoBRk tCZjenfCXkXiTGvrIWdDNejFnK6RHJ5JOzERFFGrBzEbKkzuctNYdEmUa/AP1+Qa HA7DJengat4fR6/wy4I5kIWsn2PlveCFLKPcssbhZV6tsCmloEPYAQ== =IqEL -----END PGP SIGNATURE----- --E6lVPAHcXg6biC3t--