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
4
votes
1 answer

How to unwind (multi-level return) the stack without catch/try/raise?

I would like to unwind the stack to an arbitrary level when catch/try is not available (i.e., the code to which I'm unwinding is out of my control). Is this possible? For example, in testing, I would like to have my tests call a method that checks…
RoUS
  • 1,888
  • 2
  • 14
  • 29
4
votes
1 answer

How to exit a process without any unwinding in C++98?

In C++11 or later, we can call std::quick_exit to exit a process without any unwinding, that is, no destructor will be called [after | during] std::quick_exit. I have a project: It has a global object, and there is a fatal bug in the destructor of…
xmllmx
  • 39,765
  • 26
  • 162
  • 323
4
votes
1 answer

Deep stack unwinding

First of all, this is definitely about C, no C++ solutions are requested. Target: Return to the caller function (A) beyond multiple stack frames. I have some solutions, but none of them feels like the best option. The easiest one in the sense of…
3
votes
0 answers

Instructions after ret, side effect of hot/cold splitting and exceptions?

I wanted to check if GCC makes sure extra code generated for running destructors when exceptions are thrown is put in a cold section of the binary, to keep those instructions away from the "happy path" and avoid contributing to instruction cache…
Joseph Garvin
  • 20,727
  • 18
  • 94
  • 165
3
votes
0 answers

Why does std::function cause the stack to be unwound only when an exception escapes the current function?

I am trying to work around this std::thread bug, which causes the stack to be unwound in an older version of gcc, by applying the noexcept annotation: #include #include void thrower() { throw std::runtime_error("A…
jszopi
  • 31
  • 2
3
votes
1 answer

mips _Unwind_Backtrace on SIGSEGV

On a mips platform, I am trying to get Unwind work. Currently if I issue print_trace manually stack trace is correctly shown as below: backtrace_helper 0x4b6958 backtrace_helper 0x4b6ab4 backtrace_helper 0x2ac2f628 Obtained 3 stack frames.…
whoi
  • 3,281
  • 7
  • 36
  • 44
3
votes
1 answer

Using libunwind for implementing exceptions

Working on a compiler, need some assistance understanding and working with libunwind. Here's what I have so far: #define UNW_LOCAL_ONLY #include #include #include #include #include typedef…
3
votes
1 answer

C++ throwing an exception from a destructor

This isn't a question on whether it's safe to throw an exception from a destructor. http://www.parashift.com/c++-faq-lite/exceptions.html#faq-17.9 states: "During stack unwinding, all the local objects in all those stack frames are destructed. If…
Trent
  • 2,328
  • 3
  • 33
  • 51
3
votes
3 answers

Getting value of stack pointer while stack unwinding with dwarf2

In DWARF2 debugging format, stack unwinding is supported with the help of CFI(Call Frame Information) present in .debug_frame section. This is precisely a table that keeps a rule for every register to get its value in previous frame. However, all of…
bbv
  • 501
  • 1
  • 5
  • 14
3
votes
3 answers

Is this use of c_str with exception undefined behavior?

I've seen several similar snippets of code that looked like this: struct MyExcept : std::exception { explicit MyExcept(const char* m) noexcept : message{m} {} const char* what() const noexcept override { return message; } …
Guillaume Racicot
  • 39,621
  • 9
  • 77
  • 141
3
votes
1 answer

How to react to stack unwinding when destructors are not supported by a language?

Suppose you have created an instance of a Window class. The window is shown to the user. Then, an exception is thrown, and reference to the instance is lost, but the window is still seen by the user because the instance still exists (it's just not…
Gui Prá
  • 5,559
  • 4
  • 34
  • 59
3
votes
1 answer

Is it safe to use RAII while stack unwinding?

class AutoSomething { public: AutoSomething(Object& ob) : object_(object) {} ~AutoSomething() { object_.some_callback(); } private: Object& object_; }; ......... void Object::some_function() { …
user1289
  • 1,251
  • 2
  • 13
  • 25
3
votes
2 answers

Is the stack unwound when you stop debugging?

Just curious if my destructors are being called. (Specifically for Visual Studio, when you hit the red stop button)
3
votes
0 answers

Using libunwind in a shared library

I want to provide a generic call stack function as part of a library (.so) using libunwind. However, executables linked against the .so start to fail as soon as I link against libunwind. As I understand it, the problem I'm running into is that…
Anteru
  • 19,042
  • 12
  • 77
  • 121
3
votes
1 answer

C++ and the callstack - can it be used to get line numbers?

I can't quite recall what library GCC works with to implement stack unwinding, which is used for c++ exceptions and call traces, and I know there's no means defined in the C++ specification, so any answers to this are platform specific. I am using…
Alec Teal
  • 5,770
  • 3
  • 23
  • 50
1 2
3
8 9