stack-unwinding

Unable to set next statement when debugging

寵の児 提交于 2019-12-06 04:17:46
问题 I am debugging my project in VS2015 and an exception is thrown in my code. When I try to set the next statement I get the error message displayed below. When I debug the same solution in VS2013 I am able to set the next statement without any problems. This behavior seems to occur for multiple kinds of exceptions. Example code that I can reproduce the problem with is shown below. When an exception is thrown on the last line in TestMethod1 I can easily move back to the 1st statement in VS2013

Stack unwinding on HP-UX and Linux

依然范特西╮ 提交于 2019-12-05 08:51:49
I need to get the stack information of my C application in certain points. I've read the documentation and searched the Net but still cannot figure out how I can do it. Can you point to a simple process explanation? Or, even better, to an example of stack unwinding. I need it for HP-UX (Itanium) and Linux. Check out linux/stacktrace.h Here is an API reference: http://www.cs.cmu.edu/afs/cs/Web/People/tekkotsu/dox/StackTrace_8h.html Should work on all Linux kernels Here is an alternative example in C from http://www.linuxjournal.com/article/6391 #include <stdio.h> #include <signal.h> #include

Scope unwinding in PHP class constructors

痞子三分冷 提交于 2019-12-05 01:21:55
I'm learning PHP classes and exceptions, and, coming from a C++ background, the following strikes me as odd: When the constructor of a derived class throws an exception, it appears that the destructor of the base class is not run automatically: class Base { public function __construct() { print("Base const.\n"); } public function __destruct() { print("Base destr.\n"); } } class Der extends Base { public function __construct() { parent::__construct(); $this->foo = new Foo; print("Der const.\n"); throw new Exception("foo"); // #1 } public function __destruct() { print("Der destr.\n"); parent::_

Stack unwinding in C++ when using Lua

徘徊边缘 提交于 2019-12-04 06:18:09
I recently stumbled into this this C++/Lua error int function_for_lua( lua_State* L ) { std::string s("Trouble coming!"); /* ... */ return luaL_error(L,"something went wrong"); } The error is that luaL_error use longjmp , so the stack is never unwound and s is never destructed, leaking memory. There are a few more Lua API's that fail to unwind the stack. One obvious solution is to compile Lua in C++ mode with exceptions. I, however, cannot as Luabind needs the standard C ABI. My current thought is to write my own functions that mimic the troublesome parts of the Lua API: // just a heads up

How does Rust know whether to run the destructor during stack unwind?

大城市里の小女人 提交于 2019-12-03 20:35:07
问题 The documentation for mem::uninitialized points out why it is dangerous/unsafe to use that function: calling drop on uninitialized memory is undefined behavior. So this code should be, I believe, undefined: let a: TypeWithDrop = unsafe { mem::uninitialized() }; panic!("=== Testing ==="); // Destructor of `a` will be run (U.B) However, I wrote this piece of code which works in safe Rust and does not seem to suffer from undefined behavior: #![feature(conservative_impl_trait)] trait T { fn disp(

Catching panic! when Rust called from C FFI, without spawning threads

徘徊边缘 提交于 2019-12-03 13:22:56
I'm working on a Rust wrapper for the Duktape JavaScript interpreter . In a normal use case, the call stack will look like this: Rust: Arbitrary application code. Rust: My library wrapper. C: The Duktape interpreter. Rust: My Rust code. Rust: Arbitrary callbacks into application code. What happens if (5) calls panic! ? According to various Rust developers on IRC, attempting to panic! from inside non-Rust callframes like (3) may result in undefined behavior. But according the Rust documentation, the only way to catch a panic! is using std::task::try , which spawns an extra thread. There's also

.Net - what is an “unwind”?

风格不统一 提交于 2019-12-01 04:18:06
While answering this question I noticed that I got the following dialog while atempting to move the "cursor" while an exception was being handled: Unable to set the next statement to this location. The attempt to unwind the callstack failed. Unwinding is not possible in the following scenarios: Debugging was started via Just-In-Time debugging. An unwind is in progress A System.StackOverflowException or System.Threading.ThreadAbortException exception has been thrown. What exactly is an unwind ? It's me! No, in this context it typically refers to the process of stepping ("backwards"/"upwards")

.Net - what is an “unwind”?

亡梦爱人 提交于 2019-12-01 01:12:32
问题 While answering this question I noticed that I got the following dialog while atempting to move the "cursor" while an exception was being handled: Unable to set the next statement to this location. The attempt to unwind the callstack failed. Unwinding is not possible in the following scenarios: Debugging was started via Just-In-Time debugging. An unwind is in progress A System.StackOverflowException or System.Threading.ThreadAbortException exception has been thrown. What exactly is an unwind

Why destructor is not called on exception?

风格不统一 提交于 2019-11-27 07:03:41
I expected A::~A() to be called in this program, but it isn't: #include <iostream> struct A { ~A() { std::cout << "~A()" << std::endl; } }; void f() { A a; throw "spam"; } int main() { f(); } However, if I change last line to int main() try { f(); } catch (...) { throw; } then A::~A() is called. I am compiling with "Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86" from Visual Studio 2005. Command line is cl /EHa my.cpp . Is compiler right as usual? What does standard say on this matter? lefticus The destructor is not being called because terminate() for the

How to get fullstacktrace using _Unwind_Backtrace on SIGSEGV

旧街凉风 提交于 2019-11-26 23:20:30
问题 I handle SIGSEGV by code: int C() { int *i = NULL; *i = 10; // Crash there } int B() { return C(); } int A() { return B(); } int main(void) { struct sigaction handler; memset(&handler,0,sizeof(handler)); handler.sa_sigaction = handler_func; handler.sa_flags = SA_SIGINFO; sigaction(SIGSEGV,&handler,NULL); return(C()); } Where handler code are: static int handler_func(int signal, siginfo_t info, void* rserved) { const void* stack[MAX_DEPTH]; StackCrowlState state; state.addr = stack; state