【问题标题】:Apache2 segmentation fault caused by custom php module自定义 php 模块导致的 Apache2 分段错误
【发布时间】:2017-05-21 06:53:43
【问题描述】:

我正靠在墙上奔跑。

对于我的一个 php 项目,我正在使用一个 php 模块,它可以使用瑞士星历表进行一些天文计算。未来的发展过程确实取决于它。所以我需要让它在php7中工作。这个 php 模块使 c 函数可以从瑞士星历(一个带有行星位置的库)中使用,以便使用模块包含在 php 中。

这个php模块的源码可以通过here找到

当为 php5 和 ubuntu 14.04 编译这个模块时,它工作正常,但是当我为 php7 和 ubuntu 16.04 编译这个模块时。

编译时确实会出错,比如这个:

/home/hermes/Bureaublad/php-sweph-master/sweph.c:1098:2: error: 
‘RETURN_STRING’ undeclared (first use in this function)
 RETURN_STRING(name, 1);

经过一些试验和错误,我确实发现这个函数中只有一个参数,因为在 php7 中已经改变了一些东西。在很多函数中删除“, 1”参数后。我终于编译了模块并且运行良好,但并非所有功能都正常工作。

有很多函数会导致 apache2 分段错误错误 (11)。同时其他功能也运行良好。

所以在阅读了一些内容后,我开始调试 apache2 以找出导致分段错误的原因,但从这一点开始,事情就没有任何意义了......

我遵循了这个指南:"[notice] child pid XXXX exit signal Segmentation fault (11)" in apache error.log

GDB 返回这个,但我看不出这与我的导致错误的 php 模块有什么关系..

 gdb attach 19966
 GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
 Copyright (C) 2016 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later    
 <http://gnu.org/licenses/gpl.html>
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.  Type "show    
 copying"
 and "show warranty" for details.
 This GDB was configured as "x86_64-linux-gnu".
 Type "show configuration" for configuration details.
 For bug reporting instructions, please see:
 <http://www.gnu.org/software/gdb/bugs/>.
 Find the GDB manual and other documentation resources online at:
 <http://www.gnu.org/software/gdb/documentation/>.
 For help, type "help".
 Type "apropos word" to search for commands related to "word"...
 attach: Bestand of map bestaat niet.
 Attaching to process 19966
 Reading symbols from /bin/bash...(no debugging symbols found)...done.
 Reading symbols from /lib/x86_64-linux-gnu/libtinfo.so.5...(no       
 debugging symbols found)...done.
 Reading symbols from /lib/x86_64-linux-gnu/libdl.so.2...Reading   
 symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libdl-2.23.so...done.
 done.
 Reading symbols from /lib/x86_64-linux-gnu/libc.so.6...Reading 
 symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libc-
 2.23.so...done.
 done.
 Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols  
 from /usr/lib/debug//lib/x86_64-linux-gnu/ld-2.23.so...done.
 done.
 Reading symbols from /lib/x86_64-linux-
 gnu/libnss_compat.so.2...Reading symbols from 
 /usr/lib/debug//lib/x86_64-linux-gnu/libnss_compat-2.23.so...done.
 done.
 Reading symbols from /lib/x86_64-linux-gnu/libnsl.so.1...Reading 
 symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libnsl-
 2.23.so...done.
 done.
 Reading symbols from /lib/x86_64-linux-gnu/libnss_nis.so.2...Reading   
 symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libnss_nis-  
 2.23.so...done.
 done.
 Reading symbols from /lib/x86_64-linux-
 gnu/libnss_files.so.2...Reading symbols from 
 /usr/lib/debug//lib/x86_64-linux-gnu/libnss_files-2.23.so...done.
 done.
 0x00007fdc29a1f4ca in __GI___waitpid (pid=-1, 
 stat_loc=0x7ffe86bd85f0, options=10)
 at ../sysdeps/unix/sysv/linux/waitpid.c:29
 29 ../sysdeps/unix/sysv/linux/waitpid.c: Bestand of map bestaat niet.
 (gdb) back
 #0  0x00007fdc29a1f4ca in __GI___waitpid (pid=-1,     
 stat_loc=0x7ffe86bd85f0, options=10)
 at ../sysdeps/unix/sysv/linux/waitpid.c:29
 #1  0x0000000000446f5d in ?? ()
 #2  0x000000000044843b in wait_for ()
 #3  0x000000000043842f in execute_command_internal ()
 #4  0x000000000043848e in execute_command ()
 #5  0x000000000042139e in reader_loop ()
 #6  0x000000000041fdb1 in main ()
 (gdb) back full
 #0  0x00007fdc29a1f4ca in __GI___waitpid (pid=-1,     
 stat_loc=0x7ffe86bd85f0, options=10)
 at ../sysdeps/unix/sysv/linux/waitpid.c:29
    resultvar = 18446744073709551104
 #1  0x0000000000446f5d in ?? ()
 No symbol table info available.
 #2  0x000000000044843b in wait_for ()
 No symbol table info available.
 #3  0x000000000043842f in execute_command_internal ()
 No symbol table info available.
 #4  0x000000000043848e in execute_command ()
 No symbol table info available.
 #5  0x000000000042139e in reader_loop ()
 No symbol table info available.
 #6  0x000000000041fdb1 in main ()
 No symbol table info available.
 (gdb) 

【问题讨论】:

    标签: segmentation-fault gdb php-extension


    【解决方案1】:
     Attaching to process 19966
     Reading symbols from /bin/bash...(no debugging symbols found)...done.
    

    您似乎附加了错误的 pid 号。即您附加到/bin/bash,您的shell 实例之一。您想附加到 Apache2 进程。再次查看ps 输出,并按照"[notice] child pid XXXX exit signal Segmentation fault (11)" in apache error.log 中的建议找到您的Apache2 实例。

    【讨论】:

    • 最终我确实找到了问题所在!感谢您指出我将错误的进程附加到 gdb。
    猜你喜欢
    • 2012-02-09
    • 2023-02-24
    • 1970-01-01
    • 2013-09-18
    • 2011-12-07
    • 1970-01-01
    • 2016-02-24
    • 1970-01-01
    • 2015-07-17
    相关资源
    最近更新 更多