Skip to content

Commit

Permalink
Debug MacOS ThreadPool bus error pt 4
Browse files Browse the repository at this point in the history
  • Loading branch information
lczech committed Feb 26, 2024
1 parent fcb21f3 commit d655104
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
35 changes: 27 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,12 @@ jobs:
- name: Test - gdb
# If the regular test run failed, we repeat with gdb, to print the stack.
# We are not using the `./test/run.sh gdb` here, to make it easier for MacOS.
# gdb on Mac needs to be code signed for executing without admin rights...
# See https://sourceware.org/gdb/wiki/PermissionsDarwin for the details.
# We tried running it via sudo instead, but that just hangs indefinitely.
if: ${{ failure() && steps.test.conclusion == 'failure' }}
run: |
GDBEXE=$(which gdb)
# We are not using the `./test/run.sh gdb` here, to make it easier for MacOS.
# gdb on Mac needs to be code signed for executing without admin rights...
# See https://sourceware.org/gdb/wiki/PermissionsDarwin for the details.
if [[ ${{ matrix.os }} == macos* ]] ; then
# GDBEXE="sudo gdb"
# Create a certificate in the System Keychain, and trust the certificate for code signing
echo "cert"
Expand All @@ -364,9 +361,31 @@ jobs:
touch ~/.gdbinit
sed -i '.bak' '/set startup-with-shell enable/d' ~/.gdbinit
sudo DevToolsSecurity -disable
# We tried running it via sudo instead, but that just hangs indefinitely.
# So now, we just run in a loop with timeout, and hope that one of the attempts works.
# That seems to be what's recommended in this case... oh macOS...
echo "run"
ATTEMPT=1
MAX_ATTEMPTS=10
TIMEOUT=120
while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
echo "Attempt $ATTEMPT of $MAX_ATTEMPTS"
gtimeout ${TIMEOUT} gdb -ex "set confirm off" -iex "set pagination off" -ex "run" -ex "thread apply all bt" -ex "quit" --args ./bin/test/genesis_tests
if [ $? -eq 0 ]; then
break
fi
((attempt++))
if [ $ATTEMPT -gt $MAX_ATTEMPTS ]; then
break
fi
sleep 1
done
else
# If we are not on macOS, things just work fine.
gdb -ex "set confirm off" -iex "set pagination off" -ex "run" -ex "thread apply all bt" -ex "quit" --args ./bin/test/genesis_tests
fi
echo "run"
${GDBEXE} -ex "set confirm off" -iex "set pagination off" -ex "run" -ex "thread apply all bt" -ex "quit" --args ./bin/test/genesis_tests
# -------------------------------------------------------
# Logs
Expand Down
6 changes: 4 additions & 2 deletions test/src/utils/core/thread_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ void thread_pool_compute_nested_fuzzy_work_(
// On macos, the stack size for spawned threads seems to be super low, and cause stack overflows
// when recursing too much. No idea what the effect of that is on real code, but at least here
// in the test case we can take care of not going too deep.
static const size_t max_rec_depth = 10;
static const size_t max_rec_depth = 5;
// if( rec_depth > 20 ) {
// LOG_DBG << "rec " << rec_depth;
// }
Expand Down Expand Up @@ -562,9 +562,11 @@ TEST( ThreadPool, NestedFuzzy )
pthread_attr_getstacksize(&attr, &stacksize);
LOG_DBG << "Default stack size = " << stacksize;

// Set a new stack size
// Set a new stack size, and check it
stacksize = 8 * 1024 * 1024; // 1 MB
pthread_attr_setstacksize(&attr, stacksize);
pthread_attr_getstacksize(&attr, &stacksize);
LOG_DBG << "New stack size = " << stacksize;

size_t const max_tests = 300;
for( size_t test_num = 0; test_num < max_tests; ++test_num ) {
Expand Down

0 comments on commit d655104

Please sign in to comment.