Skip to content

Commit

Permalink
Fix: stacktrace logging at Segmentation Fault (#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnzbk authored Dec 13, 2024
1 parent 8e9bb2f commit 3eb54ff
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 178 deletions.
43 changes: 22 additions & 21 deletions .github/workflows/osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
workflow_call:
workflow_dispatch:

env:
BUILD_TYPES: ${{ (github.ref_name == 'develop' || github.ref_name == 'main') && 'release debug' || 'release' }}
BUILD_TESTING: ${{ (github.ref_name != 'main') && 'testing' || '' }}

jobs:
build-x64:
runs-on: [self-hosted, macos, x64]
Expand All @@ -14,12 +18,7 @@ jobs:
uses: actions/checkout@v4

- name: Build
run: |
if [ "$GITHUB_REF_NAME" != "main" ]; then
bash osx/build-nzbget.sh x64 testing
else
bash osx/build-nzbget.sh x64
fi
run: bash osx/build-nzbget.sh x64 ${{ env.BUILD_TYPES }} ${{ env.BUILD_TESTING }}

- name: Upload full build log on failure
uses: actions/upload-artifact@v4
Expand All @@ -36,7 +35,7 @@ jobs:
SUFFIX="${GITHUB_REF_NAME/\//-}"
for FILE in *.zip; do
[ -f $FILE ] || continue
NEW_FILE=${FILE/-bin-macos-x64.zip/-$SUFFIX-bin-macos-x64.zip}
NEW_FILE=${FILE/-bin-macos-x64/-$SUFFIX-bin-macos-x64}
mv $FILE $NEW_FILE
done
Expand All @@ -56,12 +55,7 @@ jobs:
uses: actions/checkout@v4

- name: Build
run: |
if [ "$GITHUB_REF_NAME" != "main" ]; then
bash osx/build-nzbget.sh universal testing
else
bash osx/build-nzbget.sh universal
fi
run: bash osx/build-nzbget.sh universal ${{ env.BUILD_TYPES }} ${{ env.BUILD_TESTING }}

- name: Upload full build log on failure
uses: actions/upload-artifact@v4
Expand All @@ -78,15 +72,15 @@ jobs:
SUFFIX="${GITHUB_REF_NAME/\//-}"
for FILE in *.zip; do
[ -f $FILE ] || continue
NEW_FILE=${FILE/-bin-macos-universal.zip/-$SUFFIX-bin-macos-universal.zip}
NEW_FILE=${FILE/-bin-macos-universal/-$SUFFIX-bin-macos-universal}
mv $FILE $NEW_FILE
done
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: nzbget-osx-installers-universal
path: build/*-universal.zip
path: build/*-universal*.zip
retention-days: 5

sign-universal:
Expand All @@ -109,17 +103,24 @@ jobs:
NOTARY_KEY_ID: ${{ secrets.OSX_NOTARY_KEY_ID }}
NOTARY_KEY_ISSUER: ${{ secrets.OSX_NOTARY_KEY_ISSUER }}
run: |
mkdir -p build
cp osx/sign/* build
cp nzbget-osx-installers-universal/*.zip build/
cd build
bash nzbget-sign.sh *.zip
mkdir -p build_signed
for FILE in nzbget-osx-installers-universal/*.zip; do
[ -f $FILE ] || continue
mkdir -p build
cp osx/sign/* build
cp $FILE build/
cd build
bash nzbget-sign.sh *.zip
cd ..
cp build/*.dmg build_signed
rm -rf build
done
- name: Upload signed build artifacts
uses: actions/upload-artifact@v4
with:
name: nzbget-osx-installers-universal-signed
path: build/*.dmg
path: build_signed/*.dmg
retention-days: 5

combine-osx-artifacts:
Expand Down
2 changes: 2 additions & 0 deletions cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ if (CMAKE_SYSTEM_PROCESSOR MATCHES "riscv32|rv32")
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEBUG 1)

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang")
add_compile_options(-Weverything -Wno-c++98-compat)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
Expand Down
3 changes: 3 additions & 0 deletions cmake/config.h.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* Define to 1 to include debug-code */
#cmakedefine DEBUG

/* Name of package */
#cmakedefine PACKAGE "@PACKAGE@"

Expand Down
4 changes: 4 additions & 0 deletions cmake/windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ find_package(Threads REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(Boost REQUIRED COMPONENTS json)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(LIBS ${LIBS} dbghelp.lib)
endif()

set(LIBS ${LIBS} Threads::Threads Boost::json LibXml2::LibXml2 winmm.lib)
set(INCLUDES ${INCLUDES} ${Boost_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR})

Expand Down
4 changes: 2 additions & 2 deletions daemon/main/StackTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void PrintBacktrace(PCONTEXT context)
srcFileName = "<filename not available>";
}

info("%s (%i) : %s", *srcFileName, lineNumber, *symName);
error("Stacktrace: %s (%i) : %s", *srcFileName, lineNumber, *symName);

if (sfStackFrame.AddrReturn.Offset == 0)
{
Expand Down Expand Up @@ -209,7 +209,7 @@ void PrintBacktrace()
error("Obtained %zd stack frames", size);
for (i = 0; i < size; i++)
{
error("%s", strings[i]);
error("Stacktrace: %s", strings[i]);
}

free(strings);
Expand Down
2 changes: 1 addition & 1 deletion lib/regex/regex.c
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ re_string_reconstruct(re_string_t* pstr, int idx, int eflags)
pstr->valid_len - offset);
pstr->valid_len -= offset;
pstr->valid_raw_len -= offset;
#if DEBUG
#ifdef DEBUG
assert(pstr->valid_len > 0);
#endif
}
Expand Down
Loading

0 comments on commit 3eb54ff

Please sign in to comment.