|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-05-28 08:20 UTC] github at fabian-franz dot de
[2013-05-28 08:36 UTC] pajoye@php.net
[2013-05-28 08:36 UTC] pajoye@php.net
-Status: Open
+Status: Duplicate
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 14:00:01 2025 UTC |
Description: ------------ Getting an object with a circular reference from memcache triggers memory corruption, sometimes leading to a segmentation fault. It looks like a zval allocated on the stack ends up being garbage collected during the destruct sequence as a result of the code within the "if (flags & MMC_SERIALIZED) {" block in mmc_unpack_value, in memcache_pool.c This may be the same problem reported at http://pecl.php.net/bugs/bug.php?id=14511, and does not seem to be present in 2.2.6 Reproduce code: --------------- Put the following in "corruption.php": <?php $obj = new StdClass(); $obj->obj = $obj; $memcache = new Memcache; $memcache->connect('127.0.0.1', 11211); $memcache->set('x', $obj, false, 300); $x = $memcache->get('x'); $x = $memcache->get('x'); Run under valgrind (assuming memcached is running on 127.0.0.1:11211): valgrind --tool=memcheck php corruption.php A potential patch: http://pastebin.com/raw.php?i=p3sJXmEk Expected result: ---------------- No errors, similar to: $ valgrind --tool=memcheck php corruption.php ==10808== Memcheck, a memory error detector ==10808== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al. ==10808== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info ==10808== Command: php corruption.php ==10808== ==10808== ==10808== HEAP SUMMARY: ==10808== in use at exit: 85,004 bytes in 2,145 blocks ==10808== total heap usage: 20,680 allocs, 18,535 frees, 2,514,693 bytes allocated ==10808== ==10808== LEAK SUMMARY: ==10808== definitely lost: 2,253 bytes in 31 blocks ==10808== indirectly lost: 2,148 bytes in 49 blocks ==10808== possibly lost: 0 bytes in 0 blocks ==10808== still reachable: 80,603 bytes in 2,065 blocks ==10808== suppressed: 0 bytes in 0 blocks ==10808== Rerun with --leak-check=full to see details of leaked memory ==10808== ==10808== For counts of detected and suppressed errors, rerun with: -v ==10808== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 216 from 13) Actual result: -------------- Lots of invalid reads and writes, similar to: http://pastebin.com/raw.php?i=Mmm5QgUP On some of my test machines it also triggers a segmentation fault.