运行时计数器退出代码 139,但 gdb 使其通过 [英] Counter exit code 139 when running, but gdb make it through

查看:18
本文介绍了运行时计数器退出代码 139,但 gdb 使其通过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题听起来很具体,但我怀疑它仍然可能是 C++ 调试问题.

My question sounds specific, but I doubt it still can be of a C++ debug issue.

我正在使用 omnet++ 来模拟无线网络.omn​​et++ 本身就是一个 c++ 程序.

I am using omnet++ which is to simulate wireless network. omnet++ itself is a c++ program.

我在运行我的程序时遇到了一个奇怪的现象(在 Ubuntu 12.04 中使用 omnet++ 4.2.2 修改了 inet 框架):当触摸代码的某个部分时,程序以退出代码 139 退出(人们说这意味着内存碎片),当我尝试调试时,gdb 不会报告模拟之前退出的有问题"代码有任何问题,实际上,调试会通过这部分代码并输出预期结果.

I encountered a queer phenomena when I run my program (modified inet framework with omnet++ 4.2.2 in Ubuntu 12.04): the program exit with exit code 139 (people say this means memory fragmentation) when touching a certain part of the codes, when I try to debug, gdb doesn't report anything wrong with the 'problematic' codes where the simulation exits previously, actually, the debug goes through this part of codes and output expected results.

gdb 版本信息:GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04

gdb version info: GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04

谁能告诉我为什么运行失败但调试没有?

Could anybody tell me why the run fails but debug doesn't?

非常感谢!

推荐答案

退出代码 139(人们说这意味着内存碎片)

exit code 139 (people say this means memory fragmentation)

不,这意味着您的程序因信号 11(Linux 和大多数其他 UNIX 上为 SIGSEGV)而死,也称为 segmentation fault.

No, it means that your program died with signal 11 (SIGSEGV on Linux and most other UNIXes), also known as segmentation fault.

谁能告诉我为什么运行失败但调试没有?

Could anybody tell me why the run fails but debug doesn't?

您的程序表现出未定义的行为,并且可以做任何事情(包括有时看起来可以正常工作).

Your program exhibits undefined behavior, and can do anything (that includes appearing to work correctly sometimes).

您的第一步应该是在 Valgrind 下运行这个程序,并修复它报告的所有错误.

Your first step should be running this program under Valgrind, and fixing all errors it reports.

如果执行上述操作后,程序仍然崩溃,那么你应该让它转储核心(ulimit -c unlimited;./a.out),然后用 GDB 分析核心转储:<代码>gdb ./a.out 核心;然后使用 where 命令.

If after doing the above, the program still crashes, then you should let it dump core (ulimit -c unlimited; ./a.out) and then analyze that core dump with GDB: gdb ./a.out core; then use where command.

这篇关于运行时计数器退出代码 139,但 gdb 使其通过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆