由自定义 php 模块引起的 Apache2 分段错误

Apache2 segmentation fault caused by custom php module

我 运行 我的头靠在墙上。

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

可以在 here

上找到此 php 模块的源代码

为 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段错误errror(11)的函数有很多。嗯,同时其他功能都在完美运行。

所以在阅读了一些内容之后,我开始调试 apache2 以找出导致分段错误的原因,但是从现在开始,一切都变得毫无意义了...

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

GDB returns 这个,但我不明白这与导致错误的 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) 
 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 实例