当前位置:网站首页>Deliverer 1.1.2 repair the problem of calling stack after using magic method

Deliverer 1.1.2 repair the problem of calling stack after using magic method

2021-09-15 07:49:21 Zhou mengkang

I'm very glad that many friends are still using this project , So as to help them solve some online problems .

If you are not familiar with the running logic of an online project , Or you don't know the source of the call to a method , Or there is an interface on the line. I don't know where it exited abnormally , And online calls are particularly time-consuming , Are more suitable for use Deliverer To solve , Help you avoid running .

https://github.com/zhoumengka...

A few days ago, a group friend encountered some problems online , Use Deliverer To investigate , But it still can't be solved immediately , So wechat contacted me . Communicated with me on the use of tools , Though through Deliverer The historical log record finally located online bug, But I also found Deliverer A problem ignored by the tool :

Because in order to minimize the loss of log output and performance , Only user-defined methods and functions are monitored , Lead to some magic methods through the system , such as __get__call.

For example, the following code

error_reporting(E_ALL);
ini_set('display_errors',true);
function aaa($a){
    return bbb($a+100);
}

function bbb($b){
    return ccc($b*100);
}

function ccc($c){
    echo 11111;
    return 1;
}

function ddd(){
    return 2;
}
class abc{
    public function test(){
        $this->aaa;
    }

    private function test2($name){
        echo $name;
        $abcd = new abcd();
        call_user_func([$abcd,"test"]);
    }

    public function __get($name)
    {
        return $this->test2($name);
    }
}

class abcd{
    public function test(){
        $this->aaa;
    }

    private function test2($name){
        $this->test3($name);
    }

    private function test3($name){
        echo $name;
    }

    public function __get($name)
    {
        return $this->test2($name);
    }
}

aaa(1234);
ddd();

$abc = new abc();
$abc->test();
$abcd = new abcd();
$abcd->test();
call_user_func([$abcd,"test"]);
24307-1630335728072334 cli /root/deliverer-main/deliverer/extension/test.php
1630335728072690|0x7ff12cc1e030|(nil)|aaa|/root/deliverer-main/deliverer/extension/test.php|56
1630335728072710|0x7ff12cc1e1a0|0x7ff12cc1e030|bbb|/root/deliverer-main/deliverer/extension/test.php|5
1630335728072712|0x7ff12cc1e220|0x7ff12cc1e1a0|ccc|/root/deliverer-main/deliverer/extension/test.php|9
1630335728072725|0x7ff12cc1e030|(nil)|ddd|/root/deliverer-main/deliverer/extension/test.php|57
1630335728072735|0x7ff12cc1e030|(nil)|abc::test|/root/deliverer-main/deliverer/extension/test.php|60
1630335728072749|0x7ff12cc1e200|0x7fff6976a640|abc::test2|/root/deliverer-main/deliverer/extension/test.php|33
1630335728072762|0x7ff12cc1e270|0x7ff12cc1e200|abcd::test|/root/deliverer-main/deliverer/extension/test.php|28
1630335728072764|0x7ff12cc1e390|0x7fff6976a060|abcd::test2|/root/deliverer-main/deliverer/extension/test.php|52
1630335728072766|0x7ff12cc1e400|0x7ff12cc1e390|abcd::test3|/root/deliverer-main/deliverer/extension/test.php|43
1630335728072772|0x7ff12cc1e030|(nil)|abcd::test|/root/deliverer-main/deliverer/extension/test.php|62
1630335728072773|0x7ff12cc1e200|0x7fff6976a640|abcd::test2|/root/deliverer-main/deliverer/extension/test.php|52
1630335728072774|0x7ff12cc1e270|0x7ff12cc1e200|abcd::test3|/root/deliverer-main/deliverer/extension/test.php|43
1630335728072777|0x7ff12cc1e030|(nil)|abcd::test|/root/deliverer-main/deliverer/extension/test.php|63
1630335728072778|0x7ff12cc1e200|0x7fff6976a640|abcd::test2|/root/deliverer-main/deliverer/extension/test.php|52
1630335728072779|0x7ff12cc1e270|0x7ff12cc1e200|abcd::test3|/root/deliverer-main/deliverer/extension/test.php|43

You can see abcd::test Two passes call_user_func, No problem , It's a callback The way , There are independent inbound and outbound , But because __get It's a systematic approach , Not recorded in the log , therefore abc::test2 and abcd::test2 Can't find
0x7fff6976a060 Parent node .

The original plan was to monitor the magic method alone , But think about it , Under the single thread model , I'll just use the timestamp , Just hang it directly under the function of the previous moment .

https://github.com/zhoumengka...

版权声明
本文为[Zhou mengkang]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/09/20210909132704142d.html

随机推荐