Skip to content

Commit 96fb41b

Browse files
authored
ci(native): run the tests against a UBSan build of the addon (#33)
A normal build of the out-of-range casts fixed in #30 passed every test, so only a sanitizer build catches that kind of bug. The new ci-ubsan mise task builds the addon with -fsanitize=undefined,float-cast-overflow -fno-sanitize-recover=all, checks the addon's object files for UBSan calls so the row cannot pass on a plain build, and runs the tests and smoke. CI runs it as the linux-x64-ubsan matrix row, and every row now names its mise task. _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
1 parent 85c5212 commit 96fb41b

4 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@ jobs:
2525
include:
2626
- target: linux-x64
2727
os: ubuntu-latest
28+
task: ci
2829
- target: linux-arm64
2930
os: ubuntu-24.04-arm
31+
task: ci
3032
- target: macos-arm64
3133
os: macos-14
34+
task: ci
35+
- target: linux-x64-ubsan
36+
os: ubuntu-latest
37+
task: ci-ubsan
3238
steps:
3339
- uses: actions/checkout@v6
3440
- uses: jdx/mise-action@v3
35-
- run: mise run ci
41+
- run: mise run ${{ matrix.task }}

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,6 @@ The package has four layers:
184184

185185
- Run: `mise run ci`
186186
- `.github/workflows/ci.yml` runs the same task. Without mise, run the steps in "Native Build" above.
187+
- UBSan build of the addon: `mise run ci-ubsan`. CI runs it as the `linux-x64-ubsan` row.
187188
- Packaged-install journeys: [`.agents/skills/verify-libghostty-vt-node/SKILL.md`](https://github.com/coder/libghostty-vt-node/blob/main/.agents/skills/verify-libghostty-vt-node/SKILL.md)
188189
- TLA+ model of the native lifecycle: [`.agents/skills/verify-native-lifecycle/SKILL.md`](https://github.com/coder/libghostty-vt-node/blob/main/.agents/skills/verify-native-lifecycle/SKILL.md)

‎mise.toml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ run = [
1414
"npm run smoke",
1515
]
1616

17+
[tasks.ci-ubsan]
18+
description = "Build the native addon with UBSan, then run tests and smoke so undefined behavior aborts the run."
19+
run = [
20+
"npm ci",
21+
"npm run build:libghostty",
22+
# GCC's "undefined" group leaves out float-cast-overflow.
23+
"CXXFLAGS=\"-fsanitize=undefined,float-cast-overflow -fno-sanitize-recover=all\" LDFLAGS=\"-fsanitize=undefined,float-cast-overflow\" npm run build:native",
24+
"nm -u $(find build/Release -name '*.o') | grep -c '__ubsan_handle_.*_abort' > /dev/null || { echo \"error: the addon was built without UBSan\" >&2; exit 1; }",
25+
"npm test",
26+
"npm run smoke",
27+
]
28+
1729
[tasks.release-prebuilds]
1830
description = "Build and verify npm-bundled Node-API prebuild artifacts."
1931
run = [

‎native/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ C++ declarations:
6767

6868
- Run (after `npm ci`): `npm run build:libghostty && npm run build:native && npm test`
6969
- Every native test skips when the addon does not load (`test/native-support.ts:nativeSupport`), so check the test output for skips.
70+
- `mise run ci-ubsan` builds the addon with UBSan (Linux, GCC), then runs the tests and smoke. Undefined behavior aborts the run. The task also fails when the addon's object files contain no UBSan checks, which means the flags did not reach g++ (`mise.toml:tasks.ci-ubsan`).
7071
- `test/workers.test.ts` checks the per-environment state in child processes with `worker_threads`. `test/terminal.test.ts` covers `feed`, `snapshot`, `resize`, `dispose`, and the `RangeError` cases of the `createTerminal` checks in the addon. No vitest test covers `formatPlain`, `formatHtml`, `includeScrollback`, the cell style fields, or the typed-array errors.
7172
- For changes to `TerminalWrap` or `InitAll`, also run the TLA+ lifecycle model: [`.agents/skills/verify-native-lifecycle/SKILL.md`](https://github.com/coder/libghostty-vt-node/blob/main/.agents/skills/verify-native-lifecycle/SKILL.md).

0 commit comments

Comments
 (0)