[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/12] Guile-DBD-postgres: Crash in GC
From: |
Linas Vepstas |
Subject: |
[PATCH 12/12] Guile-DBD-postgres: Crash in GC |
Date: |
Fri, 19 Sep 2008 09:23:33 -0500 |
User-agent: |
Mutt/1.5.15+20070412 (2007-04-11) |
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 <address@hidden>
---
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;
signature.asc
Description: Digital signature
- [PATCH 2/12] Guile-DBI: minor cleanup, (continued)
- [PATCH 2/12] Guile-DBI: minor cleanup, Linas Vepstas, 2008/09/19
- [PATCH 3/12] Guile-DBI: Fix memory leak, Linas Vepstas, 2008/09/19
- [PATCH 4/12] Guile-DBII: replace deprecated gh_ functions, Linas Vepstas, 2008/09/19
- [PATCH 6/12] Guile-DBI: Fix crash, avoid recursive free, Linas Vepstas, 2008/09/19
- [PATCH 5/12] Guile-DBI: Use remember_upto_here, Linas Vepstas, 2008/09/19
- [PATCH 7/12] Guile-DBI: Don't cast away const, Linas Vepstas, 2008/09/19
- [PATCH 8/12] Guile-DBD-postgres: Fix handling of float point columns, Linas Vepstas, 2008/09/19
- [PATCH 9/12] Guile-DBD-postgres: Avoid discouraged functions, Linas Vepstas, 2008/09/19
- [PATCH 10/12] Guile-DBD-postgres: Fix off-by-one when fetching rows, Linas Vepstas, 2008/09/19
- [PATCH 11/12] Guile-DBD-postgres: Avoid deprecated functions, Linas Vepstas, 2008/09/19
- [PATCH 12/12] Guile-DBD-postgres: Crash in GC,
Linas Vepstas <=
- Re: PATCH [0/12]: Guile-DBI and Guile-DBD-Postgres, Neil Jerram, 2008/09/19
Re: PATCH [0/12]: Guile-DBI and Guile-DBD-Postgres, Mike Gran, 2008/09/19