Skip to main content
Filter by
Sorted by
Tagged with
2 votes
2 answers
145 views

What happens if an exception leaves a destructor *not* during stack unwinding?

I'm experimenting with writing a Design-by-Contract library. One of my types is defined as: #include <stdexcept> #include <type_traits> #include <utility> template <typename T, ...
jdc's user avatar
  • 722
1 vote
0 answers
47 views

Interpreting xdata and pdata section to hand write RUNTIME_FUNCTION and UNWIND_INFO for RtlAddFunctionTable

I am trying to inject some assembly code at runtime to circumvent a restriction in my language's runtime (VBA). I was originally writing assembly by hand compiling with flat assembler fasm, but found ...
Greedo's user avatar
  • 5,503
0 votes
0 answers
114 views

Unwinding Stack on Cortex-M with FreeRTOS: Handling Interrupts and Stopping Conditions

I am writing an unwinder for a Cortex-M (an ARM processor) running FreeRTOS. It mostly works, and I can trace the stack in many cases, but I have encountered a few issues that I haven't been able to ...
Theo Bessel's user avatar
2 votes
0 answers
194 views

How to manually unwind the stack with RtlUnwind without using exceptions or error handling

I'm looking to unwind the stack conditionally and at a predetermined number of layers. doing this with RtlUnwind gives one of two errors depending on how you use it. A malformed function table was ...
Badasahog's user avatar
  • 701
0 votes
0 answers
15 views

Does a pure C program need to follow the part of ABI about proper prologue or .xdata when compiled on Win64?

Let's say, if I don't care exceptions -- I will neither throw nor catch a exception, or need I exceptions pass through the pure C stack. Then do I need to care the xdata or SEH things? That is, are ...
ntysdd's user avatar
  • 1,264
1 vote
1 answer
51 views

the value does not change recursion during the stack unwinding

void reverseLinkedList(Node* &head) { if (head == nullptr || head->next == nullptr) { return ; } Node* Rest = head->next; reverseLinkedList(Rest); head-&...
aslam louati's user avatar
2 votes
1 answer
130 views

Why are perf back traces on Linux skipping a function (or showing a call to _init), with DWARF, LBR, and even FP (frame pointers)?

I have a simple program that I compile with -O0 -g -fno-omit-frame-pointer -fno-inline, and which I record with system-wide recording timeout 3 perf record -a -g -F 99 -- ./program perf script > ...
meisel's user avatar
  • 2,399
-1 votes
1 answer
124 views

Does exception handling work if the throw block and landing pad are in diffrent section? [closed]

Consider below case, Which ends up crashing with unwinder complaining _URC_END_OF_STACK and no handler found in _UA_SEARCH_PHASE class array{ public: int foo() { throw 5; } }; int main() { ...
Kishan Parmar's user avatar
0 votes
0 answers
173 views

Exception Handling in C++ Implementation: What is the "alternative function entry point", entered by the unwinding library to destruct local objects?

Here is a very simple file in c++ class C { public: C(){} ~C(){} }; void g() { throw std::exception(); } void f() { C c; g(); } int main() { return 0; } LLVM produces the ...
alex35833's user avatar
  • 117
0 votes
1 answer
259 views

How to produce usable callstack on ARM?

I develop C++ application on ARM (Raspberry Pi, g++ (Raspbian 8.3.0-6+rpi1) 8.3.0 ). When I try to debug my code or the application crashes in my code, I get the correct callstack without any problem. ...
bigmuscle's user avatar
  • 449
3 votes
1 answer
1k views

.eh_frame vs .debug_frame section?

The .debug_frame section seems to contain stack unwinding information and is defined by the dwarf standard. The .eh_frame section seems to basically contain the same information with some subtle ...
Fee's user avatar
  • 851
3 votes
0 answers
130 views

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 ...
Joseph Garvin's user avatar
3 votes
2 answers
428 views

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

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 ...
einpoklum's user avatar
  • 130k
2 votes
1 answer
869 views

What is the machinery behind stack unwinding?

I'm trying to understand the machinery behind stack unwinding in C++. In other words I'm interested in how this feature is implemented (and whether that is a part of the standard). So, the thread ...
Dmitry Kuzminov's user avatar
0 votes
0 answers
219 views

STM32 sudden binary size increase

I am currently playing around with embedded C++ programming, I am trying to understand the C HAL provided by ST, rework it in modern C++, optimize some stuff away, etc. I got to the point where I can ...
Marcell Juhász's user avatar
1 vote
1 answer
193 views

Converting an prel31 address to the actual address from an .ARM.exidx section

I want to learn about ARM stack unwinding and for this reason, I took a closer look into the .ARM.exidx section of my binary. The binary was build using gcc for arm, little endian, for an Cortex M0 ...
Essometer's user avatar
0 votes
0 answers
122 views

how dwarf format caculate provious sp pointer

this is example is from dwarf document. How Can I caculate provious sp(r7) pointer,I mean It didnot save sp somewhere since sp is a callee-save register. The architectural ABI committee specifies that ...
radong's user avatar
  • 45
0 votes
2 answers
462 views

Does std::move leave stack fragmented or is the stack rearranged after moving an object to the caller?

I have read several answers and and many articles about move semantic so it is simply a static cast to rvalue reference, this question is about its influence on the stack, so is the stack left ...
muaz's user avatar
  • 599
0 votes
1 answer
138 views

When 'nested stack unwinding' is OK?

AS I understand that we can not throw exceptions from dtor, and the reason is said like: "if an exception was thrown inside 'stack unwinding', then there is no clear way to handle 'nested ...
grizzlybears's user avatar
0 votes
0 answers
501 views

unwind causing segmentation fault

I am using backward-cpp (https://github.com/bombela/backward-cpp) to print the stack trace. However, this gives segmentation fault. Following is the gdb trace of the stack : 0x00007ffff608e357 in ...
Proy's user avatar
  • 346
2 votes
1 answer
756 views

How to print stacktrace once an exception is thrown before the catch block (stack unwinding)

Let's say we have the following code: #include <exception> void funcA() { funcB(); } void funcB() { funcC(); } void funcC() { funcD(); } void funcD() { throw std::...
Mazen Al Khatib's user avatar
0 votes
1 answer
654 views

glibc: unable to get unwind information for certain sections

I am currently facing issue with the glibc v2.22 where I am not able to get the proper unwind information. When there is SIGABRT application, it is calling abort function from glibc. It should be ...
Aliasgar's user avatar
0 votes
1 answer
460 views

Why .eh_frame and .eh_frame_hdr does not exist in the clang 32bit so?

I'm trying to use the command readelf -S libtest.so on the 32bit libtest.so which compiled with clang11 --target=arm-linux-androideabi21 -march=armv7-a & cflags -funwind-table -fno-exceptions. The ...
ZengQ's user avatar
  • 11
2 votes
1 answer
534 views

On ARM macOS when explicitly raise()-ing a signal, some return addresses are garbled on the stack

Here's a simple program for ARM macOS that installs a signal handler for SIGSEGV, then generates one. In the signal handler function, the stack is walked with the usual frame pointer chasing algorithm,...
Donpedro's user avatar
  • 848
0 votes
1 answer
230 views

How to uninstall RtlInstallFunctionTableCallback?

What is the reverse of the RtlInstallFunctionTableCallback function ? I have been looking at it to avoid the rather slow RtlAddFunctionTable/RtlDeleteFunctionTable for transient JIT'ed math ...
Eric Grange's user avatar
  • 6,201
1 vote
1 answer
419 views

How to detect stack unwinding in C++20 coroutines?

The typical advice in C++ is to detect stack unwinding in the destructor using std::uncaught_exceptions(), see the example from https://en.cppreference.com/w/cpp/error/uncaught_exception : struct Foo {...
Fedor's user avatar
  • 20.7k
1 vote
1 answer
648 views

perf record with --call-stack fp fails to unwind main function

I have a C++ test program that keeps the CPU busy: #include <cstdint> #include <iostream> // Linear-feedback shift register uint64_t lfsr1(uint64_t max_ix) { uint64_t start_state = ...
nnnmmm's user avatar
  • 8,644
2 votes
0 answers
495 views

How can linking a static library break C++ exception handling?

I had a recent problem where a thrown C++ exception was not caught and instead leads to program termination. My current MWE is: #include <stdexcept> #include <cupti.h> void foo(){ ...
Flamefire's user avatar
  • 5,777
0 votes
0 answers
1k views

Do I need to call unlock() at the end of the loop (for a local unique_lock)?

Is this: std::mutex mutex; for () { std::unique_lock<mutex> lock(mutex); // do something lock.unlock(); } Equivalent to this in terms of releasing and acquiring the lock every ...
Evandro Coan's user avatar
  • 9,378
0 votes
2 answers
616 views

How can I debug x64 windows exceptions?

I'm curious how Windows handles exceptions. More exactly, how Windows find the catch block of a try / catch. I saw that the compiler makes a separate function in assembly for catch block. Since the ...
Maco's user avatar
  • 21
0 votes
1 answer
644 views

RBP register value in windbg windows stack

If i have code flow like main()--> a()--> b()-->c(), if I break in debugger(windbg) at c() and dump register values of all frames in debugger as ".frame /r frame_number"......do i ...
Naveen's user avatar
  • 121
3 votes
0 answers
451 views

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 <functional> #include <...
jszopi's user avatar
  • 31
5 votes
1 answer
737 views

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<T> are examples which are not unwind safe. The general idea is that any mutable state which can be ...
little-dude's user avatar
  • 1,654
2 votes
2 answers
68 views

Why program cannot reach proper return instruction after stack unwinding?

Compiler: g++ 9.2.0 Operating system: Windows 10 g++ call: g++ -E main.cpp -v -o main.i g++ -c main.cpp -v -o main.o g++ main.o -v -o main.exe main.exe main.cpp: #include <chrono> #...
Gaurav Goswami's user avatar
1 vote
2 answers
432 views

How to see result of MASM directives such as PROC, .SETFRAME. .PUSHREG

Writing x64 Assembly code using MASM, we can use these directives to provide frame unwinding information. For example, from .SETFRAME definition: These directives do not generate code; they only ...
Alex F's user avatar
  • 43.2k
3 votes
1 answer
1k views

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 <libunwind.h> #include <stdio.h> #include &...
Alex Covington's user avatar
2 votes
2 answers
942 views

Why do we need the DWARF eh_frame emitted by compilers?

I have red that eh_frame is needed for stack unwinding during debugging or when our code hits an exception. Now my questions is, can't the debugger just walk the stack and figure out the boundaries ...
user avatar
4 votes
1 answer
237 views

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 ...
Hemantharaju .H's user avatar
1 vote
1 answer
459 views

C++ Exception not caught, program terminates with abort

This program terminates before the exception handler is caught void main(){ try{ work1(); std::thread joinableThread( [](){ work2(); } )...
Lefteris Eleftheriades's user avatar
3 votes
0 answers
301 views

During C++ stack unwind during exception, where is local exception value stored

I am familiar with the mental model of a C++ exception, and how it can be controlled programatically. For example, everything in this answer :SO Question on topic What bewilders me, however, is how ...
schulmaster's user avatar
10 votes
0 answers
3k views

Is it possible to unwind on panic in `#![no_std]` mode?

Is it possible to unwind on panic in #![no_std] mode, e.g. with a customized #[panic_handler]?
updogliu's user avatar
  • 6,235
1 vote
0 answers
179 views

Why does the program terminates abruptly? [duplicate]

#include <iostream> using namespace std; class B { public: ~B() { throw 42; } }; int main() { try { B obj; throw 32; } catch( int i ) { cout<<i<...
Dinesh Gowda's user avatar
  • 1,144
1 vote
1 answer
718 views

_Unwind_ and unw_ functions (LLVM's libunwind)

I'm new to the LLVM's libunwind library. Could you please tell me what's the purpose and the difference of the two sets of functions that libunwind provides: functions with the prefix _Unwind_ ...
embedc's user avatar
  • 1,645
2 votes
1 answer
529 views

Is it possible to generate unwind table on an object file

The background is that we have a prebuilt object file without unwind table, but somehow gcc unwind had problem backtracking on the object. Is it possible to generate unwind table without source code? ...
Bill Randerson's user avatar
0 votes
1 answer
403 views

Manipulating x64 Unwind Info To Match Assembly Hook

Edit: I appear to have been mistaken, the backtrace works wonderfully from anywhere on Linux -- it is only when remote debugging from gdb on ubuntu to remote windows that the stacktrace gets ...
user6567423's user avatar
0 votes
1 answer
573 views

How unwind back trace works internally?

This question is just for understanding purpose. What does _Unwind_Backtrace do internally to keep track of stack of function calls called. Does some of unwind library code executes internally ...
Pendyala's user avatar
  • 645
0 votes
0 answers
2k views

Is there a Windows kernel function to unwind the stack?

I was wondering if there's a function available from a Windows kernel driver that can unwind the stack to get (nested) function addresses that called the current function? This stuff:
MikeF's user avatar
  • 1,093
1 vote
0 answers
272 views

Breaking a stack/call frame information chain on ELF/Linux?

I'm trying to do a rather niche thing which is essentially breaking the CFI (Call Frame Information in DWARF EH info) and rbp & rsp links between frames. Main reason for that is that is that past ...
Kristina's user avatar
  • 16.3k
0 votes
0 answers
63 views

Some calls cause stack unwinding, though no C++ exception is thrown

I use Visual Studio Native Unit Test Framework for C++. When an assertion fails, next statements aren't executed and local objects destructors are called, so it seems like an exception is thrown, but ...
undermind's user avatar
  • 1,841
1 vote
1 answer
2k views

Is there a way to get DisableUserModeCallbackFilter to work in Windows 10?

Is there any way to get DisableUserModeCallbackFilter (or similar) to work on Windows 10? It's supposed to allow exceptions thrown from user-mode code to propagate across user/kernel boundaries, and ...
user541686's user avatar
  • 210k