[libunwind] [libunwind] fix pc range condition check bug (PR #154902)
Wu Yingcong via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 22 00:23:28 PDT 2025
https://github.com/yingcong-wu created https://github.com/llvm/llvm-project/pull/154902
There is an off-by-one error with current condition check for PC fallen into the range or not. There is another check within libunwind that use the correct checks in https://github.com/llvm/llvm-project/blob/5050da7ba18fc876f80fbeaaca3564d3b4483bb8/libunwind/src/UnwindCursor.hpp#L2757
```
if ((fdeInfo.pcStart <= pc) && (pc < fdeInfo.pcEnd))
```
>From 57ebc553828bf696b4bde30789e609ba96e94d6d Mon Sep 17 00:00:00 2001
From: Wu Yingcong <yingcong.wu at intel.com>
Date: Fri, 22 Aug 2025 15:16:47 +0800
Subject: [PATCH] fix missing by one bug
---
libunwind/src/DwarfParser.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libunwind/src/DwarfParser.hpp b/libunwind/src/DwarfParser.hpp
index 7e85025dd054d..25250e0810987 100644
--- a/libunwind/src/DwarfParser.hpp
+++ b/libunwind/src/DwarfParser.hpp
@@ -273,7 +273,7 @@ bool CFI_Parser<A>::findFDE(A &addressSpace, pint_t pc, pint_t ehSectionStart,
pint_t pcRange = addressSpace.getEncodedP(
p, nextCFI, cieInfo->pointerEncoding & 0x0F);
// Test if pc is within the function this FDE covers.
- if ((pcStart < pc) && (pc <= pcStart + pcRange)) {
+ if ((pcStart <= pc) && (pc < pcStart + pcRange)) {
// parse rest of info
fdeInfo->lsda = 0;
// check for augmentation length
More information about the cfe-commits
mailing list