[英]Crashing C++ application on production machine due to segmentation fault
We are facing C++ application crash issue due to segmentation fault on RED hat Linux. 由于RED hat Linux上的分段错误,我们面临C ++应用程序崩溃的问题。 We are using embedded python in C++.
我们在C ++中使用嵌入式python。
Please find below my limitation 请在我的限制以下找到
Please find below the efforts we have putted in. 请在下面找到我们付出的努力。
I appreciate any help to guide us to proceed further to solve the problem. 感谢您为指导我们进一步解决问题提供的帮助。
Below is the version details 以下是版本详细信息
Red hat linux server 5.6 (Tikanga) Python 2.6.2 GCC 4.1 Red Hat Linux服务器5.6(Tikanga)Python 2.6.2 GCC 4.1
Following is the stack trace I am getting from the core dump files they have shared (on my machine). 以下是我从它们共享的核心转储文件(在我的计算机上)中获得的堆栈跟踪。 FYI, We don't have access to production machine to run gdb on core dump files.
仅供参考,我们无权使用生产机器在核心转储文件上运行gdb。
0 0x00000033c6678630 in ?? ()
1 0x00002b59d0e9501e in PyString_FromFormatV (format=0x2b59d0f2ab00 "can't multiply sequence by non-int of type '%.200s'", vargs=0x46421f20) at Objects/stringobject.c:291
2 0x00002b59d0ef1620 in PyErr_Format (exception=0x2b59d1170bc0, format=<value optimized out>) at Python/errors.c:548
3 0x00002b59d0e4bf1c in PyNumber_Multiply (v=0x2aaaac080600, w=0x2b59d116a550) at Objects/abstract.c:1192
4 0x00002b59d0ede326 in PyEval_EvalFrameEx (f=0x732b670, throwflag=<value optimized out>) at Python/ceval.c:1119
5 0x00002b59d0ee2493 in call_function (f=0x7269330, throwflag=<value optimized out>) at Python/ceval.c:3794
6 PyEval_EvalFrameEx (f=0x7269330, throwflag=<value optimized out>) at Python/ceval.c:2389
7 0x00002b59d0ee2493 in call_function (f=0x70983f0, throwflag=<value optimized out>) at Python/ceval.c:3794
8 PyEval_EvalFrameEx (f=0x70983f0, throwflag=<value optimized out>) at Python/ceval.c:2389
9 0x00002b59d0ee2493 in call_function (f=0x6f1b500, throwflag=<value optimized out>) at Python/ceval.c:3794
10 PyEval_EvalFrameEx (f=0x6f1b500, throwflag=<value optimized out>) at Python/ceval.c:2389
11 0x00002b59d0ee2493 in call_function (f=0x2aaab09d52e0, throwflag=<value optimized out>) at Python/ceval.c:3794
12 PyEval_EvalFrameEx (f=0x2aaab09d52e0, throwflag=<value optimized out>) at Python/ceval.c:2389
13 0x00002b59d0ee2d9f in ?? () at Python/ceval.c:2968 from /usr/local/lib/libpython2.6.so.1.0
14 0x0000000000000007 in ?? ()
15 0x00002b59d0e83042 in lookdict_string (mp=<value optimized out>, key=0x46424dc0, hash=40722104) at Objects/dictobject.c:412
16 0x00002aaab09d5458 in ?? ()
17 0x00002aaab09d5458 in ?? ()
18 0x00002aaab02a91f0 in ?? ()
19 0x00002aaab0b2c3a0 in ?? ()
20 0x0000000000000004 in ?? ()
21 0x00000000026d5eb8 in ?? ()
22 0x00002aaab0b2c3a0 in ?? ()
23 0x00002aaab071e080 in ?? ()
24 0x0000000046422bf0 in ?? ()
25 0x0000000046424dc0 in ?? ()
26 0x00000000026d5eb8 in ?? ()
27 0x00002aaab0987710 in ?? ()
28 0x00002b59d0ee2de2 in PyEval_EvalFrame (f=0x0) at Python/ceval.c:538
29 0x0000000000000000 in ?? ()
You are almost certainly doing something bad with pointers in your C++ code, which can be very tough to debug. 几乎可以肯定,在C ++代码中使用指针做不好的事情,这很难调试。
std::vector
(C++03) or std::array
(C++11) so you can iterate using begin()
and end()
and you can index using at()
. std::vector
(C ++ 03)或std::array
(C ++ 11)替换数组,以便可以使用begin()
和end()
进行迭代,并可以使用at()
进行索引。 std::unique_ptr
(C++11) or boost::scoped_ptr
wherever you can (there should be no overhead in release builds). std::unique_ptr
(C ++ 11)或boost::scoped_ptr
(发行版中应该没有开销)。 Replace the rest with shared_ptr
or weak_ptr
. shared_ptr
或weak_ptr
替换其余部分。 Any that can't be replaced are probably the source of problematic logic. Because of the very problems you're seeing, modern C++ allows almost all raw pointer usage to be removed entirely. 由于您遇到的问题非常严重,现代C ++几乎可以完全删除所有原始指针用法。 Try it.
试试吧。
First things first, compile both your binary and libpython
with debug symbols and push it out. 首先,用调试符号编译二进制文件和
libpython
并将其推出。 The stack trace will be much easier to follow. 堆栈跟踪将更容易遵循。
The relevant argument to g++
is -g
. g++
的相关参数是-g
。
Suggestions: 建议:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.