C++ this=0x0 在各种帧中进行回溯
C++ backtrace with this=0x0 in various frames
我在 mips 多核系统中有一个程序,我从核心得到一个回溯,真的很难弄清楚(至少对我来说),我想也许其他内核之一写入 mem,但并非所有堆栈都已损坏,这让我更加困惑。
在帧 #2 中,这是 NULL,在帧 #0 中,这也是 NULL(核心转储的原因)。
这是(部分)回溯:
#0 E::m (this=0x0, string=0x562f148 ", size=202) at E.cc:315#1 在 P::e 中0x00000000105c773c (this=0x361ecd00, string=0x562f148 ", size=202, offset=28) 在 P.cc:137#2 0x00000000105c8c5c in M::e (this=0x0, id=7 '\a', r=2, string=0x562f148 ", size=202, oneClass=0x562f148 ", secondClass=0x14eff439 ",偏移量=28)在 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 在 A::trigger (this=0x4431fd70, triggerType=ONE, string=0x562f148 ", size=0, up=true) 中的 0x0000000010597364 at A.cc:2084#5 0x000000001059bcf0在 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=) 在 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(无符号字符常量*字符串,无符号整数大小, 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 无符号 int const 偏移量 = 值 - engine_->getData(); 450 451 int ret=未知; 452 米 *人; 453 for(const void* match=it.next(); 454 ret == 未知 && 匹配 != 空; 455 match = it.next()){ 456 p = (M*)匹配; 457 if(p->needMore()){ 458 ret = p->e(id_, getIndex(), value, len, hClass, fHClass, offset);
this=0x0
实际上很容易发生。 例如:
E *instance = NULL;
instance->method();
this
将在 method
内为 NULL。
无需假设内存已损坏或堆栈已被覆盖。 事实上,如果堆栈的其余内容似乎有意义(并且您似乎认为它们有意义),那么堆栈可能没问题。
不必查找内存损坏,而是检查逻辑以查看是否有未初始化的 (NULL) 指针或引用。
无法看到所有代码,很难想象发生了什么。您能否也添加 M::e() 和 P::e() 的代码,或者至少添加重要部分的代码。
可能解决所有问题的事情是添加一个 NULL 检查,如下 m::find():
456 p = (M*)match;
if(!p) { return; /* or do whatever */ }
457 if(p->needMore()){
458 ret = p->e(id_, getIndex(), value, len, hClass, fHClass, offset);
如果p
是 NULL,我本来以为它会在调用 p->needMore()
时崩溃,但根据该方法的作用,它可能不会崩溃。
相关文章:
- 当回溯以零开始时,如何调试崩溃
- 表示"accepting anything for this template argument" C++概念的通配符
- 为什么使用 "this" 指针调用派生成员函数?
- 回溯C++不打印函数,因此文件
- C++错误:"error: int aaa::bbb is protected within this context"
- 我可以将调用类的"this"传递给 lambda 函数吗?
- 创建具有 new in 函数和"this is nullptr"异常的对象
- 关于C++中具有多重继承"this"指针的说明
- 在noexcept 规范中是否允许使用"this"?
- 如何修复"error: ‘_1’ was not declared in this scope"?
- C++调用具有 *this 属性的单个帮助程序函数
- Doees the 'this' 指针参与虚函数的多态行为
- 在 c++ 中正确定义"this"关键字?
- 这是使用回溯的 nqueen 问题,但我使用了动态 2d 数组,我的程序编译良好,但不返回任何输出
- 在什么情况下,两个堆栈分配的结构对象的 this 点指向同一个地址?
- "Unable to start debugging. No process is associated with this object." - 在Visual Studio Code中使用GDB
- QObject::连接无法将信号连接到*this*对象的插槽
- 析构函数中的"delete this"
- 如何解释GDB中回溯的模板函数签名?
- C++ this=0x0 在各种帧中进行回溯