PHP 退出并出现“双重释放或损坏”错误
Posted
技术标签:
【中文标题】PHP 退出并出现“双重释放或损坏”错误【英文标题】:PHP exits with "double free or corruption" error 【发布时间】:2014-01-28 18:17:26 【问题描述】:当我的 cli 脚本完成它的工作(见下文)然后整个解释器被转储核心时,我遇到了一个非常奇怪的错误。
这发生在 ubuntu 12.04 和 13.10(来自官方网站的每日图片)以及 php 5.5.3(来自 13.10 的包)和 5.5.8(从源代码编译)。
环境是 vagrant x64 box。
有人可以提出任何可能的解决方案吗,我已经花了 2 天的时间来解决问题并且没有解决方案。
*** Error in `php': double free or corruption (out): 0x0000000002203aa0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x80996)[0x7f87ae7f5996]
php(sapi_shutdown+0x17)[0x6940f7]
php(main+0x3bf)[0x461a6f]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7f87ae796de5]
php[0x461c5b]
======= Memory map: ========
00400000-00bf0000 r-xp 00000000 08:01 67085 /usr/bin/php5
00def000-00e90000 r--p 007ef000 08:01 67085 /usr/bin/php5
00e90000-00e9c000 rw-p 00890000 08:01 67085 /usr/bin/php5
00e9c000-00eba000 rw-p 00000000 00:00 0
02203000-028ae000 rw-p 00000000 00:00 0 [heap]
7f87a37ed000-7f87a37f3000 r-xp 00000000 08:01 2030 /lib/x86_64-linux-gnu/libnss_dns-2.17.so
7f87a37f3000-7f87a39f2000 ---p 00006000 08:01 2030 /lib/x86_64-linux-gnu/libnss_dns-2.17.so
7f87a39f2000-7f87a39f3000 r--p 00005000 08:01 2030 /lib/x86_64-linux-gnu/libnss_dns-2.17.so
7f87a39f3000-7f87a39f4000 rw-p 00006000 08:01 2030 /lib/x86_64-linux-gnu/libnss_dns-2.17.so
7f87a39f4000-7f87a3a00000 r-xp 00000000 08:01 2062 /lib/x86_64-linux-gnu/libnss_files-2.17.so
7f87a3a00000-7f87a3bff000 ---p 0000c000 08:01 2062 /lib/x86_64-linux-gnu/libnss_files-2.17.so
7f87a3bff000-7f87a3c00000 r--p 0000b000 08:01 2062 /lib/x86_64-linux-gnu/libnss_files-2.17.so
7f87a3c00000-7f87a3c01000 rw-p 0000c000 08:01 2062 /lib/x86_64-linux-gnu/libnss_files-2.17.so
7f87a5f44000-7f87a5f59000 r-xp 00000000 08:01 2181 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f87a5f59000-7f87a6158000 ---p 00015000 08:01 2181 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f87a6158000-7f87a6159000 r--p 00014000 08:01 2181 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f87a6159000-7f87a615a000 rw-p 00015000 08:01 2181 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f87a615a000-7f87a6240000 r-xp 00000000 08:01 4028 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.18
7f87a6240000-7f87a643f000 ---p 000e6000 08:01 4028 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.18
7f87a643f000-7f87a6447000 r--p 000e5000 08:01 4028 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.18
7f87a6447000-7f87a6449000 rw-p 000ed000 08:01 4028 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.18
7f87a6449000-7f87a645e000 rw-p 00000000 00:00 0
7f87ae1ad000-7f87ae336000 r--p 00000000 08:01 60739 /usr/lib/locale/locale-archive
7f87ae336000-7f87ae357000 r-xp 00000000 08:01 2083 /lib/x86_64-linux-gnu/liblzma.so.5.0.0
7f87ae357000-7f87ae556000 ---p 00021000 08:01 2083 /lib/x86_64-linux-gnu/liblzma.so.5.0.0
7f87ae556000-7f87ae557000 r--p 00020000 08:01 2083 /lib/x86_64-linux-gnu/liblzma.so.5.0.0
7f87ae557000-7f87ae558000 rw-p 00021000 08:01 2083 /lib/x86_64-linux-gnu/liblzma.so.5.0.0
7f87ae558000-7f87ae56f000 r-xp 00000000 08:01 2076 /lib/x86_64-linux-gnu/libpthread-2.17.so
7f87ae56f000-7f87ae76f000 ---p 00017000 08:01 2076 /lib/x86_64-linux-gnu/libpthread-2.17.so
7f87ae76f000-7f87ae770000 r--p 00017000 08:01 2076 /lib/x86_64-linux-gnu/libpthread-2.17.so
7f87ae770000-7f87ae771000 rw-p 00018000 08:01 2076 /lib/x86_64-linux-gnu/libpthread-2.17.so
7f87ae771000-7f87ae775000 rw-p 00000000 00:00 0
7f87ae775000-7f87ae932000 r-xp 00000000 08:01 2089 /lib/x86_64-linux-gnu/libc-2.17.so
7f87ae932000-7f87aeb32000 ---p 001bd000 08:01 2089 /lib/x86_64-linux-gnu/libc-2.17.so
7f87aeb32000-7f87aeb36000 r--p 001bd000 08:01 2089 /lib/x86_64-linux-gnu/libc-2.17.so
7f87aeb36000-7f87aeb38000 rw-p 001c1000 08:01 2089 /lib/x86_64-linux-gnu/libc-2.17.so
7f87aeb38000-7f87aeb3d000 rw-p 00000000 00:00 0
7f87aeb3d000-7f87aec99000 r-xp 00000000 08:01 4499 /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.1
7f87aec99000-7f87aee98000 ---p 0015c000 08:01 4499 /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.1
7f87aee98000-7f87aeea0000 r--p 0015b000 08:01 4499 /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.1
7f87aeea0000-7f87aeea2000 rw-p 00163000 08:01 4499 /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.1
7f87aeea2000-7f87aeea3000 rw-p 00000000 00:00 0
7f87aeea3000-7f87aeea6000 r-xp 00000000 08:01 2091 /lib/x86_64-linux-gnu/libdl-2.17.so
7f87aeea6000-7f87af0a5000 ---p 00003000 08:01 2091 /lib/x86_64-linux-gnu/libdl-2.17.so
7f87af0a5000-7f87af0a6000 r--p 00002000 08:01 2091 /lib/x86_64-linux-gnu/libdl-2.17.so
7f87af0a6000-7f87af0a7000 rw-p 00003000 08:01 2091 /lib/x86_64-linux-gnu/libdl-2.17.so
7f87af0a7000-7f87af1aa000 r-xp 00000000 08:01 2195 /lib/x86_64-linux-gnu/libm-2.17.so
7f87af1aa000-7f87af3a9000 ---p 00103000 08:01 2195 /lib/x86_64-linux-gnu/libm-2.17.so
7f87af3a9000-7f87af3aa000 r--p 00102000 08:01 2195 /lib/x86_64-linux-gnu/libm-2.17.so
7f87af3aa000-7f87af3ab000 rw-p 00103000 08:01 2195 /lib/x86_64-linux-gnu/libm-2.17.so
7f87af3ab000-7f87af3e8000 r-xp 00000000 08:01 2176 /lib/x86_64-linux-gnu/libpcre.so.3.13.1
7f87af3e8000-7f87af5e8000 ---p 0003d000 08:01 2176 /lib/x86_64-linux-gnu/libpcre.so.3.13.1
7f87af5e8000-7f87af5e9000 r--p 0003d000 08:01 2176 /lib/x86_64-linux-gnu/libpcre.so.3.13.1
7f87af5e9000-7f87af5ea000 rw-p 0003e000 08:01 2176 /lib/x86_64-linux-gnu/libpcre.so.3.13.1
7f87af5ea000-7f87af5f9000 r-xp 00000000 08:01 2225 /lib/x86_64-linux-gnu/libbz2.so.1.0.4
7f87af5f9000-7f87af7f8000 ---p 0000f000 08:01 2225 /lib/x86_64-linux-gnu/libbz2.so.1.0.4
7f87af7f8000-7f87af7f9000 r--p 0000e000 08:01 2225 /lib/x86_64-linux-gnu/libbz2.so.1.0.4
7f87af7f9000-7f87af7fa000 rw-p 0000f000 08:01 2225 /lib/x86_64-linux-gnu/libbz2.so.1.0.4
7f87af7fa000-7f87af967000 r-xp 00000000 08:01 4356 /usr/lib/x86_64-linux-gnu/libdb-5.1.so
7f87af967000-7f87afb66000 ---p 0016d000 08:01 4356 /usr/lib/x86_64-linux-gnu/libdb-5.1.so
7f87afb66000-7f87afb6c000 r--p 0016c000 08:01 4356 /usr/lib/x86_64-linux-gnu/libdb-5.1.so
7f87afb6c000-7f87afb6d000 rw-p 00172000 08:01 4356 /usr/lib/x86_64-linux-gnu/libdb-5.1.so
7f87afb6d000-7f87afbc1000 r-xp 00000000 08:01 2056 /lib/x86_64-linux-gnu/libssl.so.1.0.0
7f87afbc1000-7f87afdc1000 ---p 00054000 08:01 2056 /lib/x86_64-linux-gnu/libssl.so.1.0.0
7f87afdc1000-7f87afdc4000 r--p 00054000 08:01 2056 /lib/x86_64-linux-gnu/libssl.so.1.0.0
7f87afdc4000-7f87afdca000 rw-p 00057000 08:01 2056 /lib/x86_64-linux-gnu/libssl.so.1.0.0
7f87afdca000-7f87afdcb000 rw-p 00000000 00:00 0
7f87afdcb000-7f87aff7d000 r-xp 00000000 08:01 2227 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
7f87aff7d000-7f87b017d000 ---p 001b2000 08:01 2227 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
7f87b017d000-7f87b0198000 r--p 001b2000 08:01 2227 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
7f87b0198000-7f87b01a3000 rw-p 001cd000 08:01 2227 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
7f87b01a3000-7f87b01a7000 rw-p 00000000 00:00 0
7f87b01a7000-7f87b01bd000 r-xp 00000000 08:01 2205 /lib/x86_64-linux-gnu/libresolv-2.17.so
7f87b01bd000-7f87b03bd000 ---p 00016000 08:01 2205 /lib/x86_64-linux-gnu/libresolv-2.17.so
7f87b03bd000-7f87b03be000 r--p 00016000 08:01 2205 /lib/x86_64-linux-gnu/libresolv-2.17.so
7f87b03be000-7f87b03bf000 rw-p 00017000 08:01 2205 /lib/x86_64-linux-gnu/libresolv-2.17.so
7f87b03bf000-7f87b03c1000 rw-p 00000000 00:00 0
7f87b03c1000-7f87b03d9000 r-xp 00000000 08:01 2049 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f87b03d9000-7f87b05d8000 ---p 00018000 08:01 2049 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f87b05d8000-7f87b05d9000 r--p 00017000 08:01 2049 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f87b05d9000-7f87b05da000 rw-p 00018000 08:01 2049 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f87b05da000-7f87b05fd000 r-xp 00000000 08:01 2095 /lib/x86_64-linux-gnu/ld-2.17.so
7f87b07e7000-7f87b07ef000 rw-p 00000000 00:00 0
7f87b07f0000-7f87b07f7000 r--s 00000000 08:01 4256 /usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache
7f87b07f9000-7f87b07fc000 rw-p 00000000 00:00 0
7f87b07fc000-7f87b07fd000 r--p 00022000 08:01 2095 /lib/x86_64-linux-gnu/ld-2.17.so
7f87b07fd000-7f87b07ff000 rw-p 00023000 08:01 2095 /lib/x86_64-linux-gnu/ld-2.17.so
7fff641e5000-7fff64206000 rw-p 00000000 00:00 0 [stack]
7fff642d9000-7fff642db000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted (core dumped)
【问题讨论】:
如果 php 崩溃到 PHP 自身 崩溃的地步,那么就存在严重错误。糟糕的插件,糟糕的编译,糟糕的库......有些事情很糟糕。 是的,这很明显,但是(可能)导致此错误的脚本编写得非常糟糕,以至于我无法定位问题。我对declare
语句和pcnt_*
函数的使用有强烈的不好的感觉,但是回溯中的sapi_shutdown
是非常令人惊讶的原因(看起来)代码中没有设置关闭处理程序(只是在所有脚本源中进行了搜索) .
更新:看起来proctitle
扩展是问题
【参考方案1】:
已经 6 年了,但是是的,最初的问题是由于不兼容的 proctitle
扩展名,虽然被设法编译,但不能与那个 php 版本正常工作。 AFAIR,当时它已经有一段时间没有维护了。
【讨论】:
以上是关于PHP 退出并出现“双重释放或损坏”错误的主要内容,如果未能解决你的问题,请参考以下文章
我的析构函数是不是给了我这个错误:*** `./main' 中的错误:双重释放或损坏(fasttop):?
使用 memset 和 freeaddrinfo 会导致双重释放或损坏错误
MySQL 重启使用 MySQL C API 导致双重释放或损坏