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 =================================================================== --- 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;