-
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
Merged
yingcong-wu
merged 14 commits into
llvm:main
from
yingcong-wu:yc/0822-libunwind-fde-pc-range
Sep 1, 2025
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
57ebc55
fix missing by one bug
yingcong-wu 3b1e1f7
empty commit
yingcong-wu fbf9b3f
add test
yingcong-wu ad2f481
update test
yingcong-wu 9fd7b57
update test
yingcong-wu 1284cb7
skip msan
yingcong-wu 1114e5c
test for CI
yingcong-wu 9e9dda6
test for CI
yingcong-wu 0b6b02c
test for CI(need a change in libunwind)
yingcong-wu fccfb5a
test for CI(need a change in libunwind)
yingcong-wu 0fc017a
test for CI(need to make the test pass to continue)
yingcong-wu be13b4d
format
yingcong-wu c927075
restore PR
yingcong-wu 6f6b064
fix test
yingcong-wu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// Manually marking the .eh_frame_hdr as DW_EH_PE_omit to make libunwind to do | ||
// the linear search. | ||
// Assuming the begining of the function is at the start of the FDE range. | ||
|
||
// clang-format off | ||
|
||
// REQUIRES: linux | ||
|
||
// TODO: Figure out why this fails with Memory Sanitizer. | ||
yingcong-wu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// XFAIL: msan | ||
|
||
// RUN: %{build} | ||
// RUN: objcopy --dump-section .eh_frame_hdr=%t_ehf_hdr.bin %t.exe | ||
// RUN: echo -ne '\xFF' | dd of=%t_ehf_hdr.bin bs=1 seek=2 count=2 conv=notrunc status=none | ||
// RUN: objcopy --update-section .eh_frame_hdr=%t_ehf_hdr.bin %t.exe | ||
// RUN: %{exec} %t.exe | ||
|
||
// clang-format on | ||
yingcong-wu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#include <assert.h> | ||
#include <libunwind.h> | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
#include <unwind.h> | ||
|
||
void f() { | ||
printf("123\n"); | ||
void *pc = __builtin_return_address(0); | ||
void *fpc = (void *)&f; | ||
void *fpc1 = (void *)((uintptr_t)fpc + 1); | ||
|
||
struct dwarf_eh_bases bases; | ||
const void *fde_pc = _Unwind_Find_FDE(pc, &bases); | ||
const void *fde_fpc = _Unwind_Find_FDE(fpc, &bases); | ||
const void *fde_fpc1 = _Unwind_Find_FDE(fpc1, &bases); | ||
printf("fde_pc = %p\n", fde_pc); | ||
printf("fde_fpc = %p\n", fde_fpc); | ||
printf("fde_fpc1 = %p\n", fde_fpc1); | ||
fflush(stdout); | ||
// assert(fde_pc != NULL); | ||
// assert(fde_fpc != NULL); | ||
// assert(fde_fpc1 != NULL); | ||
// assert(fde_fpc == fde_fpc1); | ||
} | ||
|
||
int main() { | ||
f(); | ||
return 0; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.