MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

try using native unwind.h instead of libunwind

+34 -43
+1 -1
.github/workflows/build-platform.yml
··· 82 82 run: | 83 83 apk add --no-cache git clang lld llvm meson ninja cmake pkgconf curl npm nodejs \ 84 84 musl-dev \ 85 - util-linux-dev util-linux-static linux-headers libunwind-dev libunwind-static xz-static \ 85 + util-linux-dev util-linux-static linux-headers libunwind-dev libunwind-static \ 86 86 py3-tomli tar xz zstd jq bash 87 87 git config --global --add safe.directory "$GITHUB_WORKSPACE" 88 88
+1 -1
BUILDING.md
··· 138 138 ```sh 139 139 apk add clang lld llvm meson ninja cmake pkgconf nodejs npm \ 140 140 musl-dev \ 141 - util-linux-dev util-linux-static linux-headers libunwind-dev libunwind-static xz-static 141 + util-linux-dev util-linux-static linux-headers libunwind-dev libunwind-static 142 142 ``` 143 143 144 144 You will also need Rust and Zig installed. The recommended approach:
+1 -10
meson/deps/meson.build
··· 51 51 win_deps = [] 52 52 endif 53 53 54 - crash_deps = [] 55 - if host_machine.system() == 'linux' and not cc.has_header('execinfo.h') 56 - libunwind_dep = dependency('libunwind', required: false, static: is_static) 57 - if libunwind_dep.found() and cc.has_header('libunwind.h', dependencies: libunwind_dep) 58 - crash_deps += [libunwind_dep] 59 - add_project_arguments('-DANT_CRASH_HAVE_LIBUNWIND', language: 'c') 60 - endif 61 - endif 62 - 63 54 deps_info = { 64 55 'lmdb': { 65 56 'dir': 'openldap-LMDB_0.9.33', ··· 243 234 uriparser_dep, utf8proc_dep, ssl_dep, crypto_dep, 244 235 zlib_dep, brotli_common_dep, brotli_dec_dep, 245 236 brotli_enc_dep, uthash_dep, lmdb_dep, wamr_dep, 246 - ] + win_deps + crash_deps 237 + ] + win_deps 247 238 248 239 if get_option('jit') 249 240 mir_dep = subproject('mir').get_variable('mir_dep')
+31 -31
src/crash.c
··· 72 72 #include <execinfo.h> 73 73 #endif 74 74 75 - #ifdef ANT_CRASH_HAVE_LIBUNWIND 76 - #define UNW_LOCAL_ONLY 77 - #include <libunwind.h> 75 + #if !defined(ANT_CRASH_HAVE_EXECINFO) && defined(__has_include) 76 + #if __has_include(<unwind.h>) 77 + #define ANT_CRASH_HAVE_UNWIND_BACKTRACE 1 78 + #include <unwind.h> 79 + #endif 80 + #endif 78 81 #endif 82 + 83 + #ifdef ANT_CRASH_HAVE_UNWIND_BACKTRACE 84 + typedef struct { 85 + uintptr_t *frames; 86 + int frame_count; 87 + int skip; 88 + } crash_unwind_state_t; 89 + 90 + static _Unwind_Reason_Code collect_unwind_frame(struct _Unwind_Context *ctx, void *arg) { 91 + crash_unwind_state_t *state = arg; 92 + uintptr_t ip = (uintptr_t)_Unwind_GetIP(ctx); 93 + if (!ip) return _URC_NO_REASON; 94 + if (state->skip > 0) { 95 + state->skip--; 96 + return _URC_NO_REASON; 97 + } 98 + if (state->frame_count >= ANT_CRASH_FRAME_MAX) return _URC_END_OF_STACK; 99 + state->frames[state->frame_count++] = ip; 100 + return _URC_NO_REASON; 101 + } 79 102 #endif 80 103 81 104 typedef struct { ··· 970 993 int skip = n > 1 ? 1 : 0; 971 994 for (int i = skip; i < n && frame_count < ANT_CRASH_FRAME_MAX; i++) 972 995 frames[frame_count++] = (uintptr_t)raw_frames[i]; 973 - #elif defined(ANT_CRASH_HAVE_LIBUNWIND) 974 - unw_cursor_t cursor; 975 - bool cursor_ready = false; 976 - bool include_current_frame = false; 977 - 978 - #ifdef UNW_INIT_SIGNAL_FRAME 979 - if (ucontext && unw_init_local2(&cursor, (unw_context_t *)ucontext, UNW_INIT_SIGNAL_FRAME) == 0) { 980 - cursor_ready = true; 981 - include_current_frame = true; 982 - } 983 - #endif 984 - 985 - unw_context_t context; 986 - if (!cursor_ready && unw_getcontext(&context) == 0 && unw_init_local(&cursor, &context) == 0) 987 - cursor_ready = true; 988 - 989 - if (cursor_ready) { 990 - if (include_current_frame) { 991 - unw_word_t ip = 0; 992 - if (unw_get_reg(&cursor, UNW_REG_IP, &ip) == 0 && ip) 993 - frames[frame_count++] = (uintptr_t)ip; 994 - } 995 - while (frame_count < ANT_CRASH_FRAME_MAX && unw_step(&cursor) > 0) { 996 - unw_word_t ip = 0; 997 - if (unw_get_reg(&cursor, UNW_REG_IP, &ip) == 0 && ip) 998 - frames[frame_count++] = (uintptr_t)ip; 999 - } 1000 - } 996 + #elif defined(ANT_CRASH_HAVE_UNWIND_BACKTRACE) 997 + (void)ucontext; 998 + crash_unwind_state_t state = { frames, 0, 1 }; 999 + _Unwind_Backtrace(collect_unwind_frame, &state); 1000 + frame_count = state.frame_count; 1001 1001 #endif 1002 1002 1003 1003 uint64_t fault_addr = info ? (uint64_t)(uintptr_t)info->si_addr : 0;