stack-unwinding

Why destructor is not called on exception?

你离开我真会死。 提交于 2019-12-17 08:56:08
问题 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

How does the JVM know where to catch an exception at runtime?

放肆的年华 提交于 2019-12-12 08:37:18
问题 From my understanding, throw is a primative jvm command. When this is called, the JVM "checks if the current call stack can catch it". if it can't, then java simply pops the call stack almost exactly as if a return was called. then the jvm "checks if the current call stack can catch it" and so on recursively. My question: how is it algorithmically possible for the JVM to know where in the call stack can catch a given exception? Is there metadata stored in each call stack entry mapping

Can I disable the “Unable to read dynamic function table entry” message in WinDbg?

佐手、 提交于 2019-12-11 05:49:30
问题 I'm working with a program that generates a lot of code at runtime, and seems not to produce any unwind data for it. (I don't have source code for this program; I'm writing a plugin for it.) When the program hangs, I break into it with WinDbg, and try to get a stack trace for all threads with ~* k . As well as the stack traces, I also get pages and pages (and pages, and more) of messages along the line of Unable to read dynamic function table entry at 00000000`2450b580 This takes a long time

Struct RUNTIME_FUNCTION

瘦欲@ 提交于 2019-12-11 04:33:55
问题 I found a large array in .pdata segment of RUNTIME_FUNCTION structures by IDA. So, where I can find information: from what it's compiled, how I can create this and how to use it in C++. Give me please books, or links with good descriptions and tutorials for exception handling and unwinding with this structure. 回答1: You can find more information on RUNTIME_FUNCTION and related structures at Microsoft's MSDN. These structures are generated by the compiler and used to implement structured

Recursive search through tree without passing object

╄→尐↘猪︶ㄣ 提交于 2019-12-11 01:54:30
问题 I'm trying to search for a node in a non-binary tree without actually passing a node to the search method. Each node has a name variable. The findChild() method takes a name, and searches through the tree it was called on to find the node with that name. To do the recursive search, I call findChild() on the child node rather than passing the child node to the findChild() method. Print statements show me that the method gets down through the tree, but the result variable gets set to null as

Stack unwinding in C++ when using Lua

倖福魔咒の 提交于 2019-12-09 16:45:11
问题 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

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

筅森魡賤 提交于 2019-12-09 09:54:26
问题 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

Destructors not executed (no stack unwinding) when exception is thrown

淺唱寂寞╮ 提交于 2019-12-08 06:24:31
问题 I found a very very weird behaviour that I have never seen before. I'm working on a complex VS2005 C++ project. class Tester { public: Tester() { TRACE("Construct Tester"); } ~Tester() { TRACE("~Destruct Tester"); } }; void Thrower() { Tester X; throw std::exception("Booom"); } What do you expect to see in Trace output when Thrower() is called? That Tester is constructed and then destructed when the stack is unwinded, or not? At least I expect that, but the destructor of Tester is never

Stack unwinding on HP-UX and Linux

蹲街弑〆低调 提交于 2019-12-07 05:42:16
问题 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. 回答1: 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

Scope unwinding in PHP class constructors

回眸只為那壹抹淺笑 提交于 2019-12-06 20:52:13
问题 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"