Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
38 changes: 35 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ jobs:
- name: Linux (GCC 13.3.0 + code-checker + valgrind)
os: ubuntu-24.04
RUN_ANALYZER: code-checker,valgrind
- name: Linux (GCC + musl + libunwind)
os: ubuntu-latest
container: alpine:3.21
APK_PACKAGES: libunwind-dev libunwind-static
CC: gcc
CXX: g++
- name: Linux (clang + musl + llvm-libunwind)
os: ubuntu-latest
container: alpine:3.21
APK_PACKAGES: clang llvm-libunwind-dev llvm-libunwind-static
CC: clang
CXX: clang++
- name: macOS 14 (xcode llvm)
os: macos-14
ERROR_ON_WARNINGS: 1
Expand Down Expand Up @@ -135,6 +147,7 @@ jobs:

name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}

env:
TEST_X86: ${{ matrix.TEST_X86 }}
Expand All @@ -149,16 +162,25 @@ jobs:
VS_GENERATOR_TOOLSET: ${{ matrix.VS_GENERATOR_TOOLSET }}

steps:
- name: Installing Alpine Linux Dependencies
if: ${{ contains(matrix.container, 'alpine') }}
run: |
apk update
apk add bash build-base cargo cmake curl curl-dev git icu linux-headers mitmproxy perl python3-dev sudo ${{ matrix.APK_PACKAGES }}
curl -sSL --retry 5 https://dot.net/v1/dotnet-install.sh | bash -eo pipefail /dev/stdin --channel 8.0 --install-dir /usr/share/dotnet
ln -s /usr/share/dotnet/dotnet /usr/local/bin/dotnet

- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-python@v5
if: ${{ !matrix.container }}
with:
python-version: "3.11"
cache: "pip"

- name: Installing Linux Dependencies
if: ${{ runner.os == 'Linux' && matrix.os != 'ubuntu-22.04' && !env['TEST_X86'] }}
if: ${{ runner.os == 'Linux' && matrix.os != 'ubuntu-22.04' && !env['TEST_X86'] && !matrix.container }}
run: |
sudo apt update
sudo apt install cmake clang-19 llvm g++-12 valgrind zlib1g-dev libcurl4-openssl-dev
Expand All @@ -173,13 +195,13 @@ jobs:
sudo make install

- name: Installing Linux GCC 9.4.0 Dependencies
if: ${{ runner.os == 'Linux' && matrix.os == 'ubuntu-22.04' && !env['TEST_X86'] }}
if: ${{ runner.os == 'Linux' && matrix.os == 'ubuntu-22.04' && !env['TEST_X86'] && !matrix.container }}
run: |
sudo apt update
sudo apt install cmake llvm kcov g++ valgrind zlib1g-dev libcurl4-openssl-dev

- name: Installing Linux 32-bit Dependencies
if: ${{ runner.os == 'Linux' && env['TEST_X86'] }}
if: ${{ runner.os == 'Linux' && env['TEST_X86'] && !matrix.container }}
run: |
sudo dpkg --add-architecture i386
sudo apt update
Expand Down Expand Up @@ -252,6 +274,16 @@ jobs:
cat /etc/hosts
shell: bash

- name: Prepare env for Alpine Linux
if: ${{ contains(matrix.container, 'alpine') }}
run: |
apk add moreutils
# comment out "::1 localhost ..." to avoid conflicts with proxy tests
sed '/^::1/ s/^/#/' /etc/hosts | sponge /etc/hosts
python3 -m venv .venv --system-site-packages
source .venv/bin/activate
echo "PATH=$PATH" >> $GITHUB_ENV

- name: Test
shell: bash
run: |
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
**Fixes**:

- Remove compile-time check for the `libcurl` feature `AsynchDNS`. ([#1206](https://github.com/getsentry/sentry-native/pull/1206))
- Support musl on Linux ([#1233](https://github.com/getsentry/sentry-native/pull/1233))

## 0.8.4

Expand Down
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ if(LINUX)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -m32 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF)
endif()

execute_process(
COMMAND ${CMAKE_C_COMPILER} -dumpmachine
OUTPUT_VARIABLE TARGET_TRIPLET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(TARGET_TRIPLET MATCHES "musl")
set(MUSL TRUE)
endif()
endif()

# CMAKE_POSITION_INDEPENDENT_CODE must be set BEFORE adding any libraries (including subprojects)
Expand Down Expand Up @@ -199,6 +208,8 @@ endif()

if(ANDROID)
set(SENTRY_WITH_LIBUNWINDSTACK TRUE)
elseif(MUSL)
set(SENTRY_WITH_LIBUNWIND TRUE)
elseif(NOT WIN32)
set(SENTRY_WITH_LIBBACKTRACE TRUE)
endif()
Expand Down Expand Up @@ -504,6 +515,15 @@ if(SENTRY_WITH_LIBUNWINDSTACK)
endif()
endif()

if(SENTRY_WITH_LIBUNWIND)
if(LINUX)
find_path(LIBUNWIND_INCLUDE_DIR libunwind.h PATH_SUFFIXES libunwind REQUIRED)
find_library(LIBUNWIND_LIBRARY unwind REQUIRED)
target_include_directories(sentry PRIVATE ${LIBUNWIND_INCLUDE_DIR})
target_link_libraries(sentry PRIVATE ${LIBUNWIND_LIBRARY})
endif()
endif()

if(SENTRY_BACKEND_CRASHPAD)
if(SENTRY_BUILD_SHARED_LIBS)
set(CRASHPAD_ENABLE_INSTALL OFF CACHE BOOL "Enable crashpad installation" FORCE)
Expand Down
2 changes: 1 addition & 1 deletion external/crashpad
6 changes: 6 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ if(SENTRY_WITH_LIBBACKTRACE)
)
endif()

if(SENTRY_WITH_LIBUNWIND)
target_compile_definitions(sentry PRIVATE SENTRY_WITH_UNWINDER_LIBUNWIND)
sentry_target_sources_cwd(sentry
unwinder/sentry_unwinder_libunwind.c
)
endif()
if(SENTRY_WITH_LIBUNWINDSTACK)
target_compile_definitions(sentry PRIVATE SENTRY_WITH_UNWINDER_LIBUNWINDSTACK)
sentry_target_sources_cwd(sentry
Expand Down
4 changes: 4 additions & 0 deletions src/unwinder/sentry_unwinder.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
DEFINE_UNWINDER(libunwindstack);
DEFINE_UNWINDER(libbacktrace);
DEFINE_UNWINDER(dbghelp);
DEFINE_UNWINDER(libunwind);

static size_t
unwind_stack(
Expand All @@ -28,6 +29,9 @@ unwind_stack(
#endif
#ifdef SENTRY_WITH_UNWINDER_DBGHELP
TRY_UNWINDER(dbghelp);
#endif
#ifdef SENTRY_WITH_UNWINDER_LIBUNWIND
TRY_UNWINDER(libunwind);
#endif
return 0;
}
Expand Down
46 changes: 46 additions & 0 deletions src/unwinder/sentry_unwinder_libunwind.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "sentry_boot.h"
#include "sentry_logger.h"
#define UNW_LOCAL_ONLY
#include <libunwind.h>

size_t
sentry__unwind_stack_libunwind(
void *addr, const sentry_ucontext_t *uctx, void **ptrs, size_t max_frames)
{
if (addr) {
return 0;
}

unw_cursor_t cursor;
if (uctx) {
int ret = unw_init_local(&cursor, (unw_context_t *)uctx->user_context);
if (ret != 0) {
SENTRY_WARN("Failed to initialize libunwind with ucontext");
return 0;
}
} else {
unw_context_t uc;
int ret = unw_getcontext(&uc);
if (ret != 0) {
SENTRY_WARN("Failed to retrieve context with libunwind");
return 0;
}

ret = unw_init_local(&cursor, &uc);
if (ret != 0) {
SENTRY_WARN("Failed to initialize libunwind with local context");
return 0;
}
}

size_t frame_idx = 0;
while (unw_step(&cursor) > 0 && frame_idx < max_frames - 1) {
unw_word_t ip = 0;
unw_get_reg(&cursor, UNW_REG_IP, &ip);
ptrs[frame_idx] = (void *)ip;
unw_word_t sp = 0;
unw_get_reg(&cursor, UNW_REG_SP, &sp);
frame_idx++;
}
return frame_idx + 1;
}
Loading