Skip to content

Commit 32dfb80

Browse files
Add a multi-threaded GC stress test, run in every GC mode
test/gc_stress builds and rewires an object graph on four threads for a set time while the main thread requests collections and compactions. It mixes cross-thread references, weak refs and weak maps, finalizers and zombies, large objects, arrays, maps, strings, closures, GC-free zones and short-lived threads, and checks every object it can still reach. The graph's size is bounded, so memory stays flat however long it runs. It prints its seed, and exits non-zero on a failed check. CI runs it for 30 seconds on every platform in the default, generational, moving, always-move, verify, generational verify, big blocks and check-pointer modes. Upstream hxcpp at e638733 fails it within seconds, with a crash or a corrupted object from a short-lived thread. Related: HaxeFoundation/hxcpp#863, HaxeFoundation/hxcpp#872, HaxeFoundation/hxcpp#740 Fixes #85
1 parent b565b66 commit 32dfb80

3 files changed

Lines changed: 517 additions & 0 deletions

File tree

‎.github/workflows/test.yml‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,52 @@ jobs:
6565
- name: run
6666
run: bin${{ inputs.sep }}${{ matrix.bin }}
6767

68+
gc_stress:
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
include:
73+
- variant: default
74+
flags: ''
75+
bin: Stress
76+
- variant: generational
77+
flags: -D HXCPP_GC_GENERATIONAL
78+
bin: Stress
79+
- variant: moving
80+
flags: -D HXCPP_GC_MOVING
81+
bin: Stress
82+
- variant: always move
83+
flags: --debug -D HXCPP_GC_DEBUG_ALWAYS_MOVE
84+
bin: Stress-debug
85+
- variant: verify
86+
flags: -D HXCPP_GC_VERIFY
87+
bin: Stress
88+
- variant: generational verify
89+
flags: -D HXCPP_GC_GENERATIONAL -D HXCPP_GC_VERIFY
90+
bin: Stress
91+
- variant: big blocks
92+
flags: -D HXCPP_GC_BIG_BLOCKS
93+
bin: Stress
94+
- variant: check pointer
95+
flags: --debug
96+
bin: Stress-debug
97+
runs-on: ${{ inputs.os }}
98+
name: '${{ inputs.label }}: gc stress (${{ matrix.variant }})'
99+
defaults:
100+
run:
101+
working-directory: test/gc_stress
102+
steps:
103+
- name: checkout
104+
uses: actions/checkout@v4
105+
- name: setup
106+
uses: ./.github/workflows/setup
107+
with:
108+
haxe: ${{ inputs.haxe }}
109+
- name: build
110+
run: haxe compile.hxml ${{ matrix.flags }} -D ${{ env.HXCPP_ARCH_FLAG }}
111+
- name: run
112+
run: bin${{ inputs.sep }}${{ matrix.bin }} 30
113+
68114
cffi:
69115
runs-on: ${{ inputs.os }}
70116
name: '${{ inputs.label }}: cffi'

0 commit comments

Comments
 (0)