Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libunwind/src/AddressSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,
}
// Try to find the unwind info using `dl_find_object`
dl_find_object findResult;
#if __has_feature(memory_sanitizer)
__builtin_memset(&findResult, 0, sizeof(dl_find_object));
#endif
if (dlFindObject && dlFindObject((void *)targetAddr, &findResult) == 0) {
if (findResult.dlfo_eh_frame == nullptr) {
// Found an entry for `targetAddr`, but there is no unwind info.
Expand Down
4 changes: 4 additions & 0 deletions libunwind/src/UnwindLevel1-gcc-ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ _LIBUNWIND_EXPORT _Unwind_Reason_Code
_Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
unw_cursor_t cursor;
unw_context_t uc;
#if __has_feature(memory_sanitizer)
__builtin_memset(&cursor, 0, sizeof(cursor));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not keen on working around the missing msan annotations on every call. This seems fragile.

__builtin_memset(&uc, 0, sizeof(uc));
#endif
__unw_getcontext(&uc);
__unw_init_local(&cursor, &uc);

Expand Down
4 changes: 4 additions & 0 deletions libunwind/src/UnwindLevel1.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,10 @@ _Unwind_ForcedUnwind(_Unwind_Exception *exception_object,
(void *)exception_object, (void *)(uintptr_t)stop);
unw_context_t uc;
unw_cursor_t cursor;
#if __has_feature(memory_sanitizer)
__builtin_memset(&uc, 0, sizeof(uc));
__builtin_memset(&cursor, 0, sizeof(cursor));
#endif
__unw_getcontext(&uc);

// Mark that this is a forced unwind, so _Unwind_Resume() can do
Expand Down
3 changes: 0 additions & 3 deletions libunwind/test/forceunwind.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

// REQUIRES: linux

// TODO: Figure out why this fails with Memory Sanitizer.
// XFAIL: msan

// Basic test for _Unwind_ForcedUnwind.
// See libcxxabi/test/forced_unwind* tests too.

Expand Down
21 changes: 9 additions & 12 deletions libunwind/test/libunwind_01.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,16 @@
// TODO: Investigate this failure on x86_64 macOS back deployment
// XFAIL: stdlib=system && target=x86_64-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0}}

// TODO: Figure out why this fails with Memory Sanitizer.
// XFAIL: msan

#include <libunwind.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

void backtrace(int lower_bound) {
unw_context_t context;
unw_context_t context = {0};
unw_getcontext(&context);

unw_cursor_t cursor;
unw_cursor_t cursor = {0};
unw_init_local(&cursor, &context);

char buffer[1024];
Expand Down Expand Up @@ -67,10 +64,10 @@ __attribute__((noinline)) void test3(int i, int j, int k) {
}

void test_no_info() {
unw_context_t context;
unw_context_t context = {0};
unw_getcontext(&context);

unw_cursor_t cursor;
unw_cursor_t cursor = {0};
unw_init_local(&cursor, &context);

unw_proc_info_t info;
Expand All @@ -87,10 +84,10 @@ void test_no_info() {
}

void test_reg_names() {
unw_context_t context;
unw_context_t context = {0};
unw_getcontext(&context);

unw_cursor_t cursor;
unw_cursor_t cursor = {0};
unw_init_local(&cursor, &context);

int max_reg_num = -100;
Expand All @@ -113,7 +110,7 @@ void test_reg_names() {

#if defined(__x86_64__)
void test_reg_get_set() {
unw_context_t context;
unw_context_t context = {0};
unw_getcontext(&context);

unw_cursor_t cursor;
Expand All @@ -134,10 +131,10 @@ void test_reg_get_set() {
}

void test_fpreg_get_set() {
unw_context_t context;
unw_context_t context = {0};
unw_getcontext(&context);

unw_cursor_t cursor;
unw_cursor_t cursor = {0};
unw_init_local(&cursor, &context);

// get/set is not implemented for x86_64 fpregs.
Expand Down
3 changes: 0 additions & 3 deletions libunwind/test/libunwind_02.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
//
//===----------------------------------------------------------------------===//

// TODO: Figure out why this fails with Memory Sanitizer.
// XFAIL: msan

// This test fails on older llvm, when built with picolibc.
// XFAIL: clang-16 && LIBCXX-PICOLIBC-FIXME

Expand Down
7 changes: 2 additions & 5 deletions libunwind/test/signal_frame.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
// TODO: Investigate this failure on Apple
// XFAIL: target={{.+}}-apple-{{.+}}

// TODO: Figure out why this fails with Memory Sanitizer.
// XFAIL: msan

// UNSUPPORTED: libunwind-arm-ehabi

// The AIX assembler does not support CFI directives, which
Expand All @@ -32,8 +29,8 @@

void test() {
asm(".cfi_signal_frame");
unw_cursor_t cursor;
unw_context_t uc;
unw_cursor_t cursor = {0};
unw_context_t uc = {0};
unw_getcontext(&uc);
unw_init_local(&cursor, &uc);
assert(unw_step(&cursor) > 0);
Expand Down
3 changes: 0 additions & 3 deletions libunwind/test/signal_unwind.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
// Ensure that the unwinder can cope with the signal handler.
// REQUIRES: target={{(aarch64|riscv64|s390x|x86_64)-.+linux.*}}

// TODO: Figure out why this fails with Memory Sanitizer.
// XFAIL: msan

// Note: this test fails on musl because:
//
// (a) musl disables emission of unwind information for its build, and
Expand Down
7 changes: 2 additions & 5 deletions libunwind/test/unw_resume.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@
// Ensure that unw_resume() resumes execution at the stack frame identified by
// cursor.

// TODO: Figure out why this fails with Memory Sanitizer.
// XFAIL: msan

#include <libunwind.h>

__attribute__((noinline)) void test_unw_resume() {
unw_context_t context;
unw_cursor_t cursor;
unw_context_t context = {0};
unw_cursor_t cursor = {0};

unw_getcontext(&context);
unw_init_local(&cursor, &context);
Expand Down
3 changes: 0 additions & 3 deletions libunwind/test/unwind_leaffunction.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
// Ensure that leaf function can be unwund.
// REQUIRES: target={{(aarch64|riscv64|s390x|x86_64)-.+linux.*}}

// TODO: Figure out why this fails with Memory Sanitizer.
// XFAIL: msan

// Note: this test fails on musl because:
//
// (a) musl disables emission of unwind information for its build, and
Expand Down
Loading