gpt4 book ai didi

在各种框架中使用 this=0x0 进行 C++ 回溯

转载 作者:行者123 更新时间:2023-11-30 02:04:41 24 4
gpt4 key购买 nike

我在 mips 多核系统中有一个程序,我从核心中得到一个回溯真的很难弄清楚(至少对我来说),我想也许其他核心之一写入内存但并非所有堆栈都已损坏是什么让我更加困惑。

在 #2 帧中这是 NULL,在 #0 帧中也是 NULL(核心转储的原因)。

这是(部分)回溯:

#0  E::m (this=0x0, string=0x562f148 "", size=202) at E.cc:315#1  0x00000000105c773c in P::e (this=0x361ecd00, string=0x562f148 "", size=202, offset=28) at P.cc:137#2  0x00000000105c8c5c in M::e (this=0x0, id=7 '\a', r=2, string=0x562f148 "", size=202, oneClass=0x562f148 "", secondClass=0x14eff439 "", offset=28) at M.cc:75                                         #3  0x0000000010596354 in m::find (this=0x4431fd70, string=0x562f148 "", size=202, oneClass=0x14eff438 "", secondClass=0x14eff439 "",                    up=false) at A.cc:458                    #4  0x0000000010597364 in A::trigger (this=0x4431fd70, triggerType=ONE, string=0x562f148 "", size=0, up=true) at A.cc:2084#5  0x000000001059bcf0 in A::findOne (this=0x4431fd70, index=2, budget=0x562f148 "", size=202, up=true) at A.cc:1155#6  0x000000001059c934 in A::shouldpathNow (this=0x4431fd70, index=2, budget=0x562f148 "", size=202, up=false, startAt=0x0, short=)   at A.cc:783    #7  0x00000000105a385c in A::shouldpath (this=0x4431fd70, index=2, rbudget=, rsize=, up=false,                   direct=) at A.cc:1104

关于 m::find 函数

    442 m_t m::find(unsigned char const *string, unsigned int size,    443                                           hClass_t *hClass, h_t *fHClass,    444                                           bool isUp) {      445       446                                                                                447   const Iterator &it=arr_[getIndex()]->getSearchIterator((char const*)value, len);    448                                                                449   unsigned int const offset = value - engine_->getData();      450                                                                                        451   int ret=UNKNOWN;                452   M *p;                        453   for(const void* match=it.next();     454       ret == UNKNOWN && match != NULL;                                                     455       match = it.next()){     456     p = (M*)match;       457 if(p->needMore()){                458       ret = p->e(id_, getIndex(), value, len, hClass, fHClass, offset);

最佳答案

this=0x0 实际上很容易发生。例如:

E *instance = NULL;
instance->method();

thismethod 中将为 NULL。

无需假设内存已损坏或堆栈已被覆盖。事实上,如果堆栈的其余内容似乎有意义(并且您似乎认为它们有意义),那么堆栈可能没问题。

不必查找内存损坏,而是检查您的逻辑以查看是否有未初始化的 (NULL) 指针或引用。

关于在各种框架中使用 this=0x0 进行 C++ 回溯,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10317840/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com