-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[libunwind] fix pc range condition check bug #154902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libunwind] fix pc range condition check bug #154902
Conversation
@llvm/pr-subscribers-libunwind Author: Wu Yingcong (yingcong-wu) ChangesThere 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 llvm-project/libunwind/src/UnwindCursor.hpp Line 2757 in 5050da7
Full diff: https://github.com/llvm/llvm-project/pull/154902.diff 1 Files Affected:
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
|
trigger ci
For stage3 (bootstrapping-build, llvm-premerge-libcxx-next-runners), I don't think the failure is related to my change.
As for the buildkite failures, I don't have a clue, but it should not relate to this change either. I see this from the log
|
We should add a regression test that fails before and passes after this change |
Added an e2e regression test. I have to manually mark the .eh_frame_hdr as omitted in order to make libunwind do the linear search, which will invoke the affected logic. I assume the function address is located at the beginning of an FDE record(I think that should be a fair assumption). Local test result:
And here is the result using libgcc_s's unwind implementation
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
As this test result shows, the test case also fails without my change to libunwind: https://github.com/llvm/llvm-project/actions/runs/17313128556/job/49152917070?pr=154902 (head is be13b4d8).
|
Hi @fmayer , do you think this PR is ready to merge based on the CI results? I don't think the failed checks are related to my change. In my opinion, it looks more like infrastructure issues.
|
Seems so to me. The same errors in a different change: https://buildkite.com/llvm-project/libcxx-ci/builds/68485/steps/canvas?sid=0198efcd-f547-4db6-a3b3-bc7b498b4e62 |
@yingcong-wu The new test fails on the Arm bots. Please fix it soon or revert to get the precommit CI green again (finally). |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/193/builds/10240 Here is the relevant piece of the build log for the reference
|
Sure, I will take a quick look now. |
Looks like there is no objcopy available for that build, I think adding the unsupport for that build would do it, I will open a PR for it.
|
Never mind, it is a cross build setup, which builds on Windows env and the binary will be copied to and run on Linux env. |
Open PR #156383 to unsupport this case. |
…ch may have cross toolchain build (#156383) In llvm/llvm-project#154902, the test failed with llvm-clang-win-x-aarch64(it is a cross-build, which builds on Windows and run on Linux, "Win to Aarch64 Linux Ubuntu Cross Toolchain"), and objdump is not available on Windows(the build env). Set to require x86 Linux instead.
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
llvm-project/libunwind/src/UnwindCursor.hpp
Line 2757 in 5050da7