Re: plpython memory leak uppon empty resultsets in all versions - Mailing list pgsql-bugs

From Tom Lane
Subject Re: plpython memory leak uppon empty resultsets in all versions
Date
Msg-id 12857.1272650988@sss.pgh.pa.us
Whole thread Raw
In response to Re: plpython memory leak uppon empty resultsets in all versions  (Andres Freund <andres@anarazel.de>)
Responses Re: plpython memory leak uppon empty resultsets in all versions  (Andres Freund <andres@anarazel.de>)
List pgsql-bugs
Andres Freund <andres@anarazel.de> writes:
> On Friday 30 April 2010 19:39:32 Tom Lane wrote:
>> Yeah.  There's a leak of the tuptable in the CATCH path, too.  Will fix.

> Yes, theres even more than that (measured it) in the error case. Will have a
> look later today.

Here's the patch I'm planning to apply --- working it back into the
back branches now.

            regards, tom lane


Index: plpython.c
===================================================================
RCS file: /cvsroot/pgsql/src/pl/plpython/plpython.c,v
retrieving revision 1.141
diff -c -r1.141 plpython.c
*** plpython.c    18 Mar 2010 19:43:03 -0000    1.141
--- plpython.c    30 Apr 2010 17:38:20 -0000
***************
*** 3147,3155 ****

                      PyList_SetItem(result->rows, i, row);
                  }
-                 PLy_typeinfo_dealloc(&args);
-
-                 SPI_freetuptable(tuptable);
              }
          }
          PG_CATCH();
--- 3147,3152 ----
***************
*** 3160,3170 ****
              if (!PyErr_Occurred())
                  PLy_exception_set(PLy_exc_error,
                         "unrecognized error in PLy_spi_execute_fetch_result");
-             Py_DECREF(result);
              PLy_typeinfo_dealloc(&args);
              return NULL;
          }
          PG_END_TRY();
      }

      return (PyObject *) result;
--- 3157,3171 ----
              if (!PyErr_Occurred())
                  PLy_exception_set(PLy_exc_error,
                         "unrecognized error in PLy_spi_execute_fetch_result");
              PLy_typeinfo_dealloc(&args);
+             SPI_freetuptable(tuptable);
+             Py_DECREF(result);
              return NULL;
          }
          PG_END_TRY();
+
+         PLy_typeinfo_dealloc(&args);
+         SPI_freetuptable(tuptable);
      }

      return (PyObject *) result;

pgsql-bugs by date:

Previous
From: Claudio Freire
Date:
Subject: Re: BUG #5443: Undetected deadlock situation
Next
From: Andres Freund
Date:
Subject: Re: plpython memory leak uppon empty resultsets in all versions