【发布时间】:2013-03-04 20:04:27
【问题描述】:
gcc (GCC) 4.5.3
GNU gdb (GDB) 7.5.50.20130309-cvs (cygwin-special)
Netbeans 7.3
在我的代码中捕获 SIGSEGV(Segment Fault Exception)时遇到了一些麻烦。 try-catch 不会捕获它(下面的代码)。这是一个不可捕获的异常吗?有什么办法可以抓到吗? (当然)我做错了什么?
艺术
string SlipStringOp::dump(const SlipCell& X) const {
stringstream pretty;
PTR ptr = *getPtr(X);
pretty << "[string ] " << dumpLink(X) << " = "
<< setfill('0') << setw(8) << hex << ptr
<< " -> ";
try {
pretty << ptr->dump();
} catch(exception& e) {
pretty << e.what();
postError(SlipErr::E3023, "SlipStringOp::dump", "", "Deletion of cell deleted the pointer.");
} catch(...) {
postError(SlipErr::E3023, "SlipStringOp::dump", "", "Deletion of cell deleted the pointer.");
}
return pretty.str();
}; // string SlipStringOp::dump(const SlipCell& X) const
【问题讨论】:
-
信号也不例外 :)
-
有什么方法可以捕捉到信号?
-
如果您真的想知道自己做错了什么,请先提供SSCCE
-
是的,你可以捕捉到一个信号,但你不应该捕捉到这个。它代表您的代码中的一个错误,您应该修复它。
-
man signal: linux.die.net/man/2/signal 这会告诉你你需要知道什么。