Questions tagged [stack-unwinding]

Stack-unwind will pop the top frame of the stack, depending on the language it may occur e.g. at the end of a code block, when returning from a called function, or during exception handling.

Stack-unwind will pop the top frame of the stack. Depending on the language this may occur e.g. at the end of a code block, when returning from a called function, or during exception handling.

Related tags: .

Related Q/A:

References:

128 questions
8
votes
2 answers

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

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…
Alexander Bird
  • 38,679
  • 42
  • 124
  • 159
7
votes
3 answers

How to detect stack unwinding in a destructor

I have a simple C++ object that I create at the start of function F() to ensure two matched functions (OpDo, OpUndo) are called at the start and return of the F(), by using the object's constructor and destructor. However, I don't want the operation…
ihamer
  • 101
  • 3
7
votes
1 answer

Stack unwinding in C++ when using Lua

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…
deft_code
  • 57,255
  • 29
  • 141
  • 224
6
votes
2 answers

C++ uncaught exception in worker thread

Uncaught exception behaves differently for main thread and another std::thread. here is the test program #include class XXX{ public: XXX(){std::fprintf(stderr, "XXX ctor\n");} ~XXX(){std::fprintf(stderr, "XXX dtor\n");} }; void…
5
votes
3 answers

Stack unwinding on HP-UX and Linux

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…
GMichael
  • 2,726
  • 1
  • 20
  • 30
5
votes
1 answer

Why does `*mut T` implement `Unwindsafe` but `&mut T` doesn't?

In the documentation for Unwindsafe we have: Types such as &mut T and &RefCell are examples which are not unwind safe. The general idea is that any mutable state which can be shared across catch_unwind is not unwind safe by default. This is…
little-dude
  • 1,544
  • 2
  • 17
  • 33
5
votes
2 answers

RAII way to get errors that are caught during destruction

In a typical example of RAII for File I/O on Wikipedia, any errors that occur when closing the file are swallowed: #include #include #include #include void write_to_file (const std::string & message) { …
Andy
  • 7,885
  • 5
  • 55
  • 61
5
votes
2 answers

Convert NULL pointer access to C++ exception under Linux/GCC

Is there any way to convert a NULL pointer access into a C++ exception under Linux ? Something similar to the NullPointerException in Java. I hope the following program would return successfully, instead of crash (assume the compiler cannot figure…
user416983
  • 974
  • 3
  • 18
  • 28
5
votes
3 answers

Use an unwind segue in didSelectRowAtIndexPath?

I have a root view controller A which push segues to a table view controller B. And when a row is selected in B. I want to use an unwind segue to go back to A and pass the text in the row back to the root view A. And then I use the the prepare for…
user3662854
5
votes
2 answers

Struct RUNTIME_FUNCTION

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…
jDek
  • 119
  • 2
  • 7
5
votes
1 answer

Exception handling and stack unwinding in R

In order to set up a coherent exception handling interface for my colleagues' and my R scripts, I would like to employ the following tryCatch structure. An outer tryCatch is wrapped around a given R script. It is used to catch and handle fatal…
cryo111
  • 4,444
  • 1
  • 15
  • 37
4
votes
1 answer

Is there any method that causes whole stack frame unwinding in C++? (except using exception)

I've been writing a continuation - in specific, coroutine - library. It's similar to std::thread (except that it's cooperative) - each execution contexts are represented in continuation object. The problem is about continuation object destruction.…
summerlight
  • 882
  • 7
  • 16
4
votes
4 answers

How can I detect whether an exception is active during destructor?

In C++, how can I detect in the body of my destructor whether the stack is being unwound due to an exception being thrown? Once detected, can I get a reference to the active exception? I ask because I'd like to add some debugging code that explains…
WilliamKF
  • 41,123
  • 68
  • 193
  • 295
4
votes
2 answers

Should I use `std::uncaught_exceptions()` to decide whether to throw an exception from my dtor?

I have a class whose ctor makes a driver call, and whose dtor makes the matching terminating/release driver call. Those calls can fail. The problem is naturally with the dtor. I am naturally aware of the common wisdom of avoiding exceptions in…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
4
votes
1 answer

If an object is created locally and thrown as an exception in C++, how can a local object be valid outside it's scope .i.e., in catch block?

Inside a try block, a function "fun()" is invoked. A local object of class "abc" is created inside "fun" and an exception is thrown. This local object is catched in "catch" block, and this has printed a proper value. As this object was created…
1
2
3
8 9