GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ia64

ia64: Make unwind backing store copy length signed

Fixes a bug where an unsigned length could wrap around, causing memory corruption during unwinding.

This commit corrects an integer underflow bug in the ia64 unwind-backing-store copy function. Previously, an unsigned length variable could wrap around to a large positive value if the source data ended unexpectedly. This caused the copy operation to read far beyond the intended buffer, potentially leading to a crash. By changing the length variable to a signed type, the underflow now results in a negative value, which correctly terminates the copy loop.

In Details

The ia64_copy_rbs function in libgcc/config/ia64/unwind-ia64.c copies sections of unwind information between NaT collection slots. The logic for handling runs that are shorter than the specified length (LEN) could lead to an unsigned integer underflow if the source data was exhausted mid-run. Changing LEN and COUNT to signed types (unw_sword) prevents this underflow, avoiding a potential infinite loop and fault. This addresses a subtle bug in how unwind table segments are managed on ia64.

For Context
NaT collection
NaT stands for 'Not a Thing'. In the context of ia64, NaT collection refers to managing registers that do not hold valid data, often used during unwinding to reconstruct the stack.
Unwinding
The process of traversing the call stack, typically used for exception handling, debugging, or retrieving backtraces. Unwinding involves accessing information stored in unwind tables.
Backing store
In the context of unwinding, the backing store refers to memory locations where register information or other necessary data for stack reconstruction is saved.
Filed Under: ia64libgccunwindingbugfix