0

【笔记】PHP一个迷惑的Segmenta...

已有 54人阅读此文 - - 未分类 - luoyy -

问题的发生:
更新php7.2后,执行php composer self-update命令,出现Segmentation fault错误。 通过gdb调试,发现问题出现在libssl.so上.

Core was generated by `php composer self-update -vvv'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f8685928e00 in ?? () from /lib/x86_64-linux-gnu/libssl.so.1.1
(gdb) bt
#0  0x00007f8685928e00 in ?? () from /lib/x86_64-linux-gnu/libssl.so.1.1
#1  0x00007f8686853f6c in SSL_CTX_new () from /usr/local/openssl/lib/libssl.so.1.0.0
#2  0x00007f868619c26c in ossl_connect_step1 () from /usr/local/lib/libcurl.so.4
#3  0x00007f868619db9f in ossl_connect_common () from /usr/local/lib/libcurl.so.4
#4  0x00007f868619e9fc in Curl_ssl_connect_nonblocking () from /usr/local/lib/libcurl.so.4
#5  0x00007f8686167536 in https_connecting () from /usr/local/lib/libcurl.so.4
#6  0x00007f8686168f13 in Curl_http_connect () from /usr/local/lib/libcurl.so.4
#7  0x00007f8686178a8d in multi_runsingle () from /usr/local/lib/libcurl.so.4
#8  0x00007f8686179b41 in curl_multi_perform () from /usr/local/lib/libcurl.so.4
#9  0x0000560ef8bb12ba in ?? ()
#10 0x0000560ef8f462ea in execute_ex ()
#11 0x0000560ef8f48468 in zend_execute ()
#12 0x0000560ef8ea2fdc in zend_execute_scripts ()
#13 0x0000560ef8e422d0 in php_execute_script ()
#14 0x0000560ef8f4aa4a in ?? ()
#15 0x0000560ef8a45618 in ?? ()
#16 0x00007f86859a30b3 in __libc_start_main (main=0x560ef8a45190, argc=4, argv=0x7fff7d9f4978, init=<optimized out>,
    fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff7d9f4968) at ../csu/libc-start.c:308
#17 0x0000560ef8a4571e in _start ()

发现/usr/local/lib/libcurl.so.4在调用ossl_connect_step1 方法之后,调用了/usr/local/openssl/lib/libssl.so.1.0.0的SSL_CTX_new ,然后后面就出问题了,突然就跳转/lib/x86_64-linux-gnu/libssl.so.1.1,然后调用了一个??(),于是我看了下连接库:

        linux-vdso.so.1 (0x00007ffd38349000)
        libcrypto.so.1.0.0 => /usr/local/openssl/lib/libcrypto.so.1.0.0 (0x00007ffbbd6c4000) // 1
        libssl.so.1.0.0 => /usr/local/openssl/lib/libssl.so.1.0.0 (0x00007ffbbd64c000) // 1
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007ffbbd630000)
        libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007ffbbd614000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ffbbd432000)
        libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007ffbbd3fa000)
        libjpeg.so.8 => /lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007ffbbd373000)
        libwebp.so.6 => /lib/x86_64-linux-gnu/libwebp.so.6 (0x00007ffbbd309000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ffbbd1ba000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ffbbd1b4000)
        libxml2.so.2 => /lib/x86_64-linux-gnu/libxml2.so.2 (0x00007ffbbcffa000)
        libcurl.so.4 => /usr/local/lib/libcurl.so.4 (0x00007ffbbcf7e000)
        libfreetype.so.6 => /lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007ffbbcebd000)
        libicuio.so.66 => /lib/x86_64-linux-gnu/libicuio.so.66 (0x00007ffbbcead000)
        libicui18n.so.66 => /lib/x86_64-linux-gnu/libicui18n.so.66 (0x00007ffbbcbae000)
        libicuuc.so.66 => /lib/x86_64-linux-gnu/libicuuc.so.66 (0x00007ffbbc9c8000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ffbbc9ad000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ffbbc7bb000)
        /lib64/ld-linux-x86-64.so.2 (0x00007ffbbe457000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ffbbc796000)
        liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007ffbbc76d000)
        libssl.so.1.1 => /lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007ffbbc6da000) // 2
        libcrypto.so.1.1 => /lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007ffbbc404000) // 2
        libicudata.so.66 => /lib/x86_64-linux-gnu/libicudata.so.66 (0x00007ffbba943000)

好家伙,libssl.so.1.1与libcrypto.so.1.1被载入了两次,并且来源于不同的目录,最终问题来源于编译时候设置了openssl的目录,但是系统又预先安装了相关的库,导致make时候CFLAGS与LIBS中已经存在系统的更新版本的动态库,so,都被引入了,于是调用curl获取https资源的时候就出现了Segmentation fault。


你喜欢下面的文章吗!Do you like the following articles?