[Pkg-postgresql-public] Bug#742493: Bug#742493: Bug#742493: pgmemcache segfaults with libmemcached11

Christoph Berg myon at debian.org
Thu May 8 13:32:18 UTC 2014


Re: To Hannu Valtonen 2014-05-02 <20140502135529.GB14306 at msgid.df7cb.de>
> Re: Hannu Valtonen 2014-05-02 <53639CE0.30908 at ohmu.fi>
> > Hi,
> > 
> > This has now been fixed by: https://github.com/ohmu/pgmemcache/commit/47623a545be485d6dd1ffb917e990d267ad57f35

Hi,

we've had a closer look at this patch. Assuming pfree() is
PostgreSQL's free() variant (which I believe it is), it looks like
using pfree() was wrong in the first place, and the standard libc
free() should be used, whatever libmemcached version is used.

I think the following patch does the right thing:

Index: pgmemcache/pgmemcache.c
===================================================================
--- pgmemcache.orig/pgmemcache.c	2014-05-08 15:25:30.260692035 +0200
+++ pgmemcache/pgmemcache.c	2014-05-08 15:27:13.164195600 +0200
@@ -818,10 +818,10 @@ static memcached_return_t server_stat_fu
     {
       char *value = memcached_stat_get_value(ptr, &stat, *stat_ptr, &rc);
       appendStringInfo(context, "%s: %s\n", *stat_ptr, value);
-      libmc_stat_free(value);
+      free(value);
     }
 
-  pfree(list);
+  free(list);
   return MEMCACHED_SUCCESS;
 }
 
Index: pgmemcache/pgmemcache.h
===================================================================
--- pgmemcache.orig/pgmemcache.h	2014-05-08 15:25:30.260692035 +0200
+++ pgmemcache/pgmemcache.h	2014-05-08 15:27:13.224195312 +0200
@@ -36,13 +36,6 @@
 #undef PACKAGE_TARNAME
 #undef PACKAGE_VERSION
 
-/* libmemcached 1.0.16 changed the allocation function for values returned from memcached_stat_get_value */
-#if LIBMEMCACHED_VERSION_HEX >= 0x01000016
-  #define libmc_stat_free free
-#else
-  #define libmc_stat_free pfree
-#endif
-
 void _PG_init(void);
 void _PG_fini(void);
 


> Do you plan to release a new version, or should I apply the patch to
> the current version in Debian for now?

Christoph
-- 
cb at df7cb.de | http://www.df7cb.de/



More information about the Pkg-postgresql-public mailing list