[PATCH] D123427: Reset _unwindInfoMissing when info is found eventually
Dimitry Andric via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 8 15:51:16 PDT 2022
dim created this revision.
dim added reviewers: compnerd, jrtc27, ldionne, MaskRay, mstorsjo, nikic.
Herald added subscribers: libcxx-commits, StephenFan.
Herald added projects: libunwind, All.
Herald added a reviewer: libunwind.
dim requested review of this revision.
Herald added a project: LLVM.
As reported in https://github.com/llvm/llvm-project/issues/54799, when
using the C APIs `unw_init_local()`, `unw_set_reg()`, `unw_get_reg()`
and `unw_step()`, sometimes libunwind can erroneously conclude there is
no unwind info available.
This is because the initial call to `co->setInfoBasedOnIPRegister()` in
`unw_init_local()` can set `_unwindInfoMissing` to `true`, as at that
point there may not yet be unwind info available.
Subsequent calls to `unw_set_reg()`, with the register parameter set to
`UNW_REG_IP`, might still be able to find unwind info based on the new
IP value, but it does *not* reset `_unwindInfoMissing` to `false` in
those cases, so follow-up calls to `unw_step()` will erroneously return
`UNW_STEP_END` immediately.
To fix this, add explicit resets of `_unwindInfoMissing` to `false`, in
the various places where `setInfoBasedOnIPRegister()` actually does find
unwind info.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D123427
Files:
libunwind/src/UnwindCursor.hpp
Index: libunwind/src/UnwindCursor.hpp
===================================================================
--- libunwind/src/UnwindCursor.hpp
+++ libunwind/src/UnwindCursor.hpp
@@ -1963,6 +1963,7 @@
if ((sects.dwarf_section != 0) && compactSaysUseDwarf(&dwarfOffset)) {
if (this->getInfoFromDwarfSection(pc, sects, dwarfOffset)) {
// found info in dwarf, done
+ _unwindInfoMissing = false;
return;
}
}
@@ -1978,8 +1979,10 @@
#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
// If there is SEH unwind info, look there next.
- if (this->getInfoFromSEH(pc))
+ if (this->getInfoFromSEH(pc)) {
+ _unwindInfoMissing = false;
return;
+ }
#endif
#if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
@@ -1987,6 +1990,7 @@
if (sects.dwarf_section != 0) {
if (this->getInfoFromDwarfSection(pc, sects)) {
// found info in dwarf, done
+ _unwindInfoMissing = false;
return;
}
}
@@ -1994,8 +1998,10 @@
#if defined(_LIBUNWIND_ARM_EHABI)
// If there is ARM EHABI unwind info, look there next.
- if (sects.arm_section != 0 && this->getInfoFromEHABISection(pc, sects))
+ if (sects.arm_section != 0 && this->getInfoFromEHABISection(pc, sects)) {
+ _unwindInfoMissing = false;
return;
+ }
#endif
}
@@ -2008,8 +2014,10 @@
typename CFI_Parser<A>::FDE_Info fdeInfo;
typename CFI_Parser<A>::CIE_Info cieInfo;
if (!CFI_Parser<A>::decodeFDE(_addressSpace, cachedFDE, &fdeInfo, &cieInfo))
- if (getInfoFromFdeCie(fdeInfo, cieInfo, pc, 0))
+ if (getInfoFromFdeCie(fdeInfo, cieInfo, pc, 0)) {
+ _unwindInfoMissing = false;
return;
+ }
}
// Lastly, ask AddressSpace object about platform specific ways to locate
@@ -2021,8 +2029,10 @@
if (!CFI_Parser<A>::decodeFDE(_addressSpace, fde, &fdeInfo, &cieInfo)) {
// Double check this FDE is for a function that includes the pc.
if ((fdeInfo.pcStart <= pc) && (pc < fdeInfo.pcEnd))
- if (getInfoFromFdeCie(fdeInfo, cieInfo, pc, 0))
+ if (getInfoFromFdeCie(fdeInfo, cieInfo, pc, 0)) {
+ _unwindInfoMissing = false;
return;
+ }
}
}
#endif // #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123427.421649.patch
Type: text/x-patch
Size: 2300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220408/62e59e0e/attachment.bin>
More information about the llvm-commits
mailing list