Hello List,

I had some difficulties today to reproduce a bug which was only
visible on the alpine container CI. So I found some way to investigate
directly from the CI.

The attached patch enables the coredumps and does a "gdb -ex 'thread
apply all bt full'" for the alpine/musl job.

I think this will help to debug a lot, I know there is also the ability
to get an artefact with the coredump, which could also be interesting,
but having the traceback on the CI page is easy.

If no one complain, I'll push the patch.

Cheers,

-- 
William Lallemand
>From 4465fe8c77aa2ce664ebfc46b41d20c4440d10cc Mon Sep 17 00:00:00 2001
From: William Lallemand <wlallem...@haproxy.org>
Date: Thu, 20 Oct 2022 15:01:01 +0200
Subject: [PATCH] CI: github: dump the backtrace of coredumps in the alpine
 container

This patch allows to show the backtrace of a coredump produced in the
alpine/musl jobs.

It activates some option required by the containers to allow the
production of coredump, set a shared directory so the kernel could dump
the coredump within the container. Some debug packages were also added.
---
 .github/workflows/musl.yml | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/musl.yml b/.github/workflows/musl.yml
index 5a6b46a7b..ff1a0f780 100644
--- a/.github/workflows/musl.yml
+++ b/.github/workflows/musl.yml
@@ -12,14 +12,21 @@ jobs:
       runs-on: ubuntu-latest
       container:
         image: alpine:latest
+        options: --privileged --ulimit core=-1 --security-opt seccomp=unconfined
+        volumes:
+          - /tmp/core:/tmp/core
       steps:
+      - name: coredump setup
+        run: |
+          ulimit -c unlimited
+          echo '/tmp/core/core.%h.%e.%t' > /proc/sys/kernel/core_pattern
       - uses: actions/checkout@v3
       - name: Install dependencies
-        run: apk add gcc make tar git python3 libc-dev linux-headers pcre-dev pcre2-dev openssl-dev lua5.3-dev grep socat curl
+        run: apk add gcc gdb make tar git python3 libc-dev linux-headers pcre-dev pcre2-dev openssl-dev lua5.3-dev grep socat curl musl-dbg lua5.3-dbg
       - name: Install VTest
         run: scripts/build-vtest.sh
       - name: Build
-        run: make -j$(nproc) CC=cc V=1 TARGET=linux-musl USE_LUA=1 LUA_INC=/usr/include/lua5.3 LUA_LIB=/usr/lib/lua5.3 USE_OPENSSL=1 USE_PCRE2=1 USE_PCRE2_JIT=1 USE_PROMEX=1
+        run: make -j$(nproc) TARGET=linux-musl DEBUG_CFLAGS='-ggdb3' CC=cc V=1 USE_LUA=1 LUA_INC=/usr/include/lua5.3 LUA_LIB=/usr/lib/lua5.3 USE_OPENSSL=1 USE_PCRE2=1 USE_PCRE2_JIT=1 USE_PROMEX=1
       - name: Show version
         run: ./haproxy -vv
       - name: Show linked libraries
@@ -30,6 +37,15 @@ jobs:
       - name: Run VTest
         id: vtest
         run: make reg-tests VTEST_PROGRAM=../vtest/vtest REGTESTS_TYPES=default,bug,devel
+      - name: Show coredumps
+        if: ${{ failure() }}
+        run: |
+          ls /tmp/core/
+          for file in /tmp/core/core.*; do
+            printf "::group::"
+            gdb -ex 'thread apply all bt full' ./haproxy $file
+            echo "::endgroup::"
+          done
       - name: Show results
         if: ${{ failure() }}
         run: |
@@ -40,3 +56,4 @@ jobs:
             echo "::endgroup::"
           done
           shopt -s nullglob
+
-- 
2.34.1

Reply via email to