On tis, 2010-08-17 at 20:55 +0300, Peter Eisentraut wrote:
> On fre, 2010-08-13 at 20:20 -0400, Tom Lane wrote:
> > According to a discussion over in Fedora-land, $subject is true:
> > http://lists.fedoraproject.org/pipermail/devel/2010-August/140995.html
> > 
> > I see several calls in plpython.c that seem to refer to PyCObject
> > stuff.
> > Anybody have any idea if we need to do something about this?
> 
> Some exception handling might be good, but I think we don't need to
> abandon the API yet.  It's only "pending deprecation".

Here is a patch.  The crash is reproducible, if warnings are turned into
errors.

Index: plpython.c
===================================================================
RCS file: /cvsroot/pgsql/src/pl/plpython/plpython.c,v
retrieving revision 1.148
diff -u -3 -p -r1.148 plpython.c
--- plpython.c	8 Jul 2010 19:00:11 -0000	1.148
+++ plpython.c	17 Aug 2010 18:45:49 -0000
@@ -1315,6 +1315,8 @@ PLy_procedure_get(FunctionCallInfo fcinf
 			elog(FATAL, "expected a PyCObject, didn't get one");
 
 		proc = PyCObject_AsVoidPtr(plproc);
+		if (!proc)
+			PLy_elog(ERROR, "PyCObject_AsVoidPtr() failed");
 		if (proc->me != plproc)
 			elog(FATAL, "proc->me != plproc");
 		/* did we find an up-to-date cache entry? */
@@ -1539,8 +1541,11 @@ PLy_procedure_create(HeapTuple procTup, 
 		PLy_procedure_compile(proc, procSource);
 
 		pfree(procSource);
+		procSource = NULL;
 
 		proc->me = PyCObject_FromVoidPtr(proc, NULL);
+		if (!proc->me)
+			PLy_elog(ERROR, "PyCObject_FromVoidPtr() failed");
 		PyDict_SetItemString(PLy_procedure_cache, key, proc->me);
 	}
 	PG_CATCH();
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to