Skip to content

Commit

Permalink
[DNM] debug macos hang
Browse files Browse the repository at this point in the history
  • Loading branch information
tavianator committed Oct 26, 2023
1 parent 70fe3b1 commit 80520dd
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push, pull_request]

jobs:
linux:
if: false
name: Linux

runs-on: ubuntu-latest
Expand Down Expand Up @@ -56,13 +57,15 @@ jobs:
- name: Run tests
run: |
export DYLD_FORCE_FLAT_NAMESPACE=1
jobs=$(sysctl -n hw.ncpu)
make -j$jobs distcheck JOBS=-j$jobs
make -j$jobs
./bin/bfs bin -exec true {} \;
freebsd:
name: FreeBSD

if: ${{ github.repository_owner == 'tavianator' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
if: ${{ false && github.repository_owner == 'tavianator' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}

runs-on: ubuntu-latest

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push]

jobs:
build:
if: false
runs-on: ubuntu-latest

steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:

jobs:
analyze:
if: false
name: Analyze
runs-on: ubuntu-latest
permissions:
Expand Down
40 changes: 40 additions & 0 deletions src/xspawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "xspawn.h"
#include "alloc.h"
#include "atomic.h"
#include "bfstd.h"
#include "config.h"
#include "list.h"
Expand All @@ -19,6 +20,45 @@
# include <paths.h>
#endif

#include "thread.h"
#include <execinfo.h>

static void *bfs_calloc(size_t count, size_t size) {
static atomic pid_t apid = 0;
pid_t pid = load(&apid, relaxed);
if (pid == 0) {
store(&apid, getpid(), relaxed);
} else {
bfs_verify(pid == getpid());
}

static thread_local bool reintr = false;
if (!reintr) {
reintr = true;
void *stack[128];
int frames = backtrace(stack, countof(stack));
backtrace_symbols_fd(stack, frames, STDERR_FILENO);
write(STDERR_FILENO, "---\n", 4);
reintr = false;
}

size = array_size(1, size, count);
void *ptr = malloc(size);
if (ptr) {
memset(ptr, 0, size);
}
return ptr;
}

__attribute__((used))
__attribute__((section("__DATA, __interpose")))
static const struct {
void *new_fn;
void *old_fn;
} interposed[] = {
{ (void *)bfs_calloc, (void *)calloc },
};

/**
* Types of spawn actions.
*/
Expand Down

0 comments on commit 80520dd

Please sign in to comment.