unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Linas Vepstas <linasvepstas@gmail.com>
To: Maurizio Boriani <baux@member.fsf.org>
Cc: Guile User Mailing List <guile-user@gnu.org>
Subject: [PATCH 12/12] Guile-DBD-postgres: Crash in GC
Date: Fri, 19 Sep 2008 09:23:33 -0500	[thread overview]
Message-ID: <20080919142333.GL13684@linas.org> (raw)
In-Reply-To: <3ae3aa420809190645o2fe2b746id80f53c5cb123e5b@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2259 bytes --]



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 <linasvepstas@gmail.com>

---
 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
===================================================================
--- guile-dbd-postgresql-2.0.0.orig/src/guile-dbd-postgresql.c	2008-09-16 19: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 = (gdbi_pgsql_ds_t*)dbh->db_info;  
   if (pgsqlP == NULL)
     {
+      if (dbh->in_free) return; /* don't scm anything if in GC */
       /* todo: error msg to be translated */
       dbh->status = 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 == NULL)
     {
-      /* todo: error msg to be translated */
-      dbh->status = scm_cons(scm_from_int(1),
-				   scm_from_locale_string("dbi connection already closed"));
+      if (0 == dbh->in_free)
+        {
+          /* todo: error msg to be translated */
+          dbh->status = scm_cons(scm_from_int(1),
+			    	   scm_from_locale_string("dbi connection already closed"));
+        }
       free(dbh->db_info);
       dbh->db_info = NULL;
       dbh->closed = SCM_BOOL_T;
@@ -207,8 +211,10 @@ __postgresql_close_g_db_handle(gdbi_db_h
   free(dbh->db_info);
   dbh->db_info = NULL;
 
-  /* todo: error msg to be translated */
   dbh->closed = SCM_BOOL_T;
+
+  if (dbh->in_free) return; /* don't scm anything if in GC */
+  /* todo: error msg to be translated */
   dbh->status = scm_cons(scm_from_int(0),
 			       scm_from_locale_string("dbi closed"));
   return;

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 481 bytes --]

  parent reply	other threads:[~2008-09-19 14:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-19 13:45 PATCH [0/12]: Guile-DBI and Guile-DBD-Postgres Linas Vepstas
2008-09-19 14:00 ` [PATCH 1/12] Guile-DBI: Avoid multiple init Linas Vepstas
2008-09-19 14:05 ` [PATCH 2/12] Guile-DBI: minor cleanup Linas Vepstas
2008-09-19 14:06 ` [PATCH 3/12] Guile-DBI: Fix memory leak Linas Vepstas
2008-09-19 14:09 ` [PATCH 4/12] Guile-DBII: replace deprecated gh_ functions Linas Vepstas
2008-09-19 14:11 ` [PATCH 6/12] Guile-DBI: Fix crash, avoid recursive free Linas Vepstas
2008-09-19 14:13 ` [PATCH 5/12] Guile-DBI: Use remember_upto_here Linas Vepstas
2008-09-19 14:15 ` [PATCH 7/12] Guile-DBI: Don't cast away const Linas Vepstas
2008-09-19 14:17 ` [PATCH 8/12] Guile-DBD-postgres: Fix handling of float point columns Linas Vepstas
2008-09-19 14:19 ` [PATCH 9/12] Guile-DBD-postgres: Avoid discouraged functions Linas Vepstas
2008-09-19 14:20 ` [PATCH 10/12] Guile-DBD-postgres: Fix off-by-one when fetching rows Linas Vepstas
2008-09-19 14:22 ` [PATCH 11/12] Guile-DBD-postgres: Avoid deprecated functions Linas Vepstas
2008-09-19 14:23 ` Linas Vepstas [this message]
2008-09-19 23:00 ` PATCH [0/12]: Guile-DBI and Guile-DBD-Postgres Neil Jerram
2008-09-19 23:22   ` Greg Troxel
2008-09-19 23:24   ` Greg Troxel
2008-09-20  0:19     ` Linas Vepstas
2008-09-20 13:25       ` Greg Troxel
2008-09-20 15:43         ` Linas Vepstas

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

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080919142333.GL13684@linas.org \
    --to=linasvepstas@gmail.com \
    --cc=baux@member.fsf.org \
    --cc=guile-user@gnu.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).