Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译swoole所用libcurl头文件和PHP 8.3所用版本不同导致Segmentation fault #5348

Closed
Appla opened this issue May 31, 2024 · 5 comments

Comments

@Appla
Copy link
Contributor

Appla commented May 31, 2024

Please answer these questions before submitting your issue.

  1. What did you do? If possible, provide a simple script for reproducing the error.
  • 系统环境

    • Rocky Linux 9
    • 安装有rpm仓库的libcurl, 版本信息如下
      curl 7.76.1 (x86_64-redhat-linux-gnu) libcurl/7.76.1 OpenSSL/3.0.7 zlib/1.2.11 nghttp2/1.43.0
      Release-Date: 2021-04-14
      
  • 重现问题

    • 自行编译curl 8.8.0 (>= 7.84.0)
    • 编译PHP 8.3 时指定前述自行编译的curl版本(>= 7.84.0都可)
      - 通过PKG_CONFIG_PATH=/path/to/curl-8.8.0/lib/pkgconfig
      - 或设置CURL_LIBS, CURL_CFLAGS
    • 编译swoole-5.1.2, 设置上述 PKG_CONFIG_PATH
    • 执行curl相关的操作, 中途涉及引用其他文件之类的,进程出现Segmentation fault崩溃掉
  • 推测

    • 编译swoole时如启用swoole-curl,默认使用系统的路径中的libcurl头文件, 且指定PKG_CONFIG_PATH并不认(config.m4未作处理),使用时swoole会在swoole_native_curl_minit中替换curl_ce的handler,从而导致php_curl_handlers和PHP内的不一致
  1. What did you expect to see?
    执行curl相关操作不会出现Segmentation fault

  2. What did you see instead?

Program received signal SIGSEGV, Segmentation fault.

#0  i_zval_ptr_dtor (zval_ptr=<optimized out>) at /path/to/php-8.3.7/Zend/zend_variables.h:43
#1  zval_ptr_dtor (zval_ptr=<optimized out>) at /path/to/php-8.3.7/Zend/zend_variables.c:84
#2  0x00007ffff606e657 in swoole_curl_verify_handlers (ch=0x7ffff6fc7a00, reporterror=0)
    at ./thirdparty/php/curl/curl_private.h:181
#3  0x00007ffff606e795 in swoole_curl_free_obj (object=0x7ffff6fc7b98)
    at /root/php/ext-swoole-5.1.2.240524-rc/thirdparty/php/curl/interface.cc:2526
#4  0x00000000009e8bbc in zend_objects_store_del (object=0x7ffff6fc7b98)
    at /path/to/php-8.3.7/Zend/zend_objects_API.c:200
#5  0x00000000009beff6 in i_zval_ptr_dtor (zval_ptr=<optimized out>)
    at /path/to/php-8.3.7/Zend/zend_variables.h:44
#6  i_free_compiled_variables (execute_data=<optimized out>) at /path/to/php-8.3.7/Zend/zend_execute.c:3880
#7  execute_ex (ex=0x0) at /path/to/php-8.3.7/Zend/zend_vm_execute.h:57075
#8  0x00000000009c7cf0 in zend_execute (op_array=0x7ffff6e77800, return_value=0x0)
    at /path/to/php-8.3.7/Zend/zend_vm_execute.h:61604
#9  0x000000000095a851 in zend_execute_scripts (type=8, retval=0x0, file_count=3)
    at /path/to/php-8.3.7/Zend/zend.c:1891
#10 0x00000000008f1386 in php_execute_script (primary_file=<optimized out>)
    at /path/to/php-8.3.7/main/main.c:2515
#11 0x0000000000a38575 in do_cli (argc=3, argv=0x1a2ccf0) at /path/to/php-8.3.7/sapi/cli/php_cli.c:966
#12 0x00000000006432d6 in main (argc=3, argv=0x1a2ccf0) at /path/to/php-8.3.7/sapi/cli/php_cli.c:1340
  1. What version of Swoole are you using (show your php --ri swoole)?
swoole

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 5.1.2
Built => May 31 2024 11:04:21
// 有修改显示编译时引用的版本
curl-native => enabled and build with 7.61.1

通过指定 CXXFLAGS="-I/path/to/curl-8.8.0/include" 问题消失

是否可以修改config.m4,在未指定CURL_CFLAGS ,从php-config读取是否有 CURL_CFLAGS或者PKGCONFIG之类的配置?
或者有其他方案

@Appla Appla changed the title 编译swoole所用libcurl头文件和PHP 8.3所用版本不通导致segment fault 编译swoole所用libcurl头文件和PHP 8.3所用版本不通导致Segmentation fault May 31, 2024
@Appla Appla changed the title 编译swoole所用libcurl头文件和PHP 8.3所用版本不通导致Segmentation fault 编译swoole所用libcurl头文件和PHP 8.3所用版本不同导致Segmentation fault May 31, 2024
@jingjingxyk
Copy link
Contributor

jingjingxyk commented May 31, 2024

着急用呢,可以尝试免安装的swoole-cli 或者 php-cli 解决对 运行环境中 相关库的依赖

@NathanFreeman
Copy link
Member

fixed by #5351

@Appla
Copy link
Contributor Author

Appla commented Jun 3, 2024

fixed by #5351

如果指定pkgconfig路径,问题解决

是否能有合理方案规避用户未指定或者说使用了和PHP不一致的头文件时能及时提醒出来,避免不兼容时在使用中才发现问题

着急用呢,可以尝试免安装的swoole-cli 或者 php-cli 解决对 运行环境中 相关库的依赖

谢谢

@matyhtf
Copy link
Member

matyhtf commented Jun 6, 2024

不好检测,建议使用 swoole-cli 。如果自行编译,是要考虑到不同路径的冲突问题,尽量使用 apt/yum 来安装基础库。

@matyhtf matyhtf closed this as completed Jun 6, 2024
@Appla
Copy link
Contributor Author

Appla commented Jun 6, 2024

不好检测,建议使用 swoole-cli 。如果自行编译,是要考虑到不同路径的冲突问题,尽量使用 apt/yum 来安装基础库。

能否文档以及configure对应配置说明中提示下libcurl版本的要求?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants