Coder Social home page Coder Social logo

Segmentation fault情况 about yaf HOT 13 CLOSED

laruence avatar laruence commented on July 17, 2024
Segmentation fault情况

from yaf.

Comments (13)

laruence avatar laruence commented on July 17, 2024

这个看起来很奇怪, 代码很简单:

 if (*(Z_STRVAL_PP(ppzval) + Z_STRLEN_PP(ppzval) - 1) == DEFAULT_SLASH) {
        YAF_G(directory) = estrndup(Z_STRVAL_PP(ppzval), Z_STRLEN_PP(ppzval) - 1);    <= 说这行呢
    } else {
        YAF_G(directory) = estrndup(Z_STRVAL_PP(ppzval), Z_STRLEN_PP(ppzval));
    }

你的配置里面application.directory是个啥?

from yaf.

skaic avatar skaic commented on July 17, 2024

application.directory 写 application 的目录,是绝对地址。

而且是这个情况不是每次请求都会发生的,是fpm运行一段时间后会出现这个情况。

from yaf.

laruence avatar laruence commented on July 17, 2024

你们的PHP是什么版本? 奇怪了, 这个代码看起来不会有问题啊. 是不是你的二进制文件搞错了, bt显示的不对?

from yaf.

skaic avatar skaic commented on July 17, 2024

php版本是5.3.10 php5-fpm,ubuntu 12.04 apt-get下来的。应该不会搞错,我是直接在报错的机器上gdb的。
我在怀疑会不会是内存泄漏,php.ini 的 memory_limit 是512M。超过限制。然后就estrndup失败了?
我简单跟了下代码,貌似这一条刚好是请求中第一个申请内存的。

from yaf.

wenjun1055 avatar wenjun1055 commented on July 17, 2024

鸟哥,在yaf_application还是在yaf_ dispatcher中之前的确有内存泄露,我找不到之前跟你的聊天记录了

from yaf.

laruence avatar laruence commented on July 17, 2024

如果estrndup失败, PHP会直接退出的, 不会core的

from yaf.

laruence avatar laruence commented on July 17, 2024

你gdb看看, 能不能打印出来ppzval的具体内容是啥

from yaf.

skaic avatar skaic commented on July 17, 2024

(gdb) bt
#0 0x00007f5c6c72b8c9 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x000000000067c2e6 in _estrndup ()
#2 0x00007f5c61d2d235 in yaf_application_parse_option (options=) at /tmp/pear/temp/yaf/yaf_application.c:143
#3 zim_yaf_application___construct (ht=, return_value=0x1aca368, return_value_ptr=, this_ptr=0x1ac6ff0, return_value_used=)
at /tmp/pear/temp/yaf/yaf_application.c:358
#4 0x000000000070f05d in ?? ()
#5 0x00000000006bfbcb in execute ()
#6 0x000000000069b130 in zend_execute_scripts ()
#7 0x00000000006477a3 in php_execute_script ()
#8 0x000000000042b895 in ?? ()
#9 0x00007f5c6c60376d in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
#10 0x000000000042c0f5 in _start ()
(gdb) up
#1 0x000000000067c2e6 in _estrndup ()
(gdb) up
#2 0x00007f5c61d2d235 in yaf_application_parse_option (options=) at /tmp/pear/temp/yaf/yaf_application.c:143
143 /tmp/pear/temp/yaf/yaf_application.c: No such file or directory.
(gdb) info locals
conf = 0x1aca1a8
ppzval = 0x1aca138
ppsval =
app = 0x1ac74e8
(gdb) p ppzval
$1 = (zval **) 0x1aca138
(gdb) x/2s 0x1aca138
0x1aca138: "\240o\254\001"
0x1aca13d: ""

这样子么?

from yaf.

laruence avatar laruence commented on July 17, 2024

恩, 然后你再p **ppzval 看看

thanks

from yaf.

skaic avatar skaic commented on July 17, 2024

(gdb) p **ppzval
$2 = {value = {lval = 28078616, dval = 1.3872679548368359e-316, str = {val = 0x1ac7218 "", len = 0}, ht = 0x1ac7218, obj = {handle = 28078616, handlers = 0x0}},
refcount__gc = 1, type = 6 '\006', is_ref__gc = 0 '\000'}

from yaf.

skaic avatar skaic commented on July 17, 2024

哦,最后 len 负一了 0.0

from yaf.

skaic avatar skaic commented on July 17, 2024

找到代码了。有这样的调用 new Yaf_Application(array("application" => array("directory"=>""))); THX 鸟哥。

from yaf.

laruence avatar laruence commented on July 17, 2024

holy shit....这个bug不应该...修复之...

from yaf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.