Skip to content

Commit b33a4de

Browse files
committed
fix(build): keep alignment checking off vendored tre.o; make SANITIZE rebuild
Two defects, one found by the other. The crash: every fixture-indexing suite (mcp, incremental, index_resilience) died on the Windows/ARM64 leg with STATUS_ILLEGAL_INSTRUCTION and no diagnostic. Cause: an earlier commit in this branch re-armed UBSan's alignment check on the vendored TRE regex engine, and CLANGARM64 builds with -fsanitize-trap, where a trap IS an illegal instruction with nothing printed. macOS and Linux stay clean under the same check because Windows is LLP64 -- 32-bit long -- so TRE's struct layouts and access widths differ there and only there. TRE is vendored third-party code we do not modify, so suppressing the check for that one object is the honest scope; every other object keeps alignment armed. Verified by bisect: origin/main, e2f5b6a and 80afcd6 all pass on Windows; the sanitizer-matrix commit that dropped the suppression is where it starts failing. The reason it took a bisect: BUILD_CONFIG_SIG covered TEST_SEAMS and CFLAGS_EXTRA but not SANITIZE, so changing sanitizer flags did not trigger a rebuild. `scripts/test.sh SANITIZE= --suites ...` -- the documented way to get a plain build for exactly this kind of trap debugging -- silently re-ran the previously instrumented binary. That produced a "it crashes without sanitizers too" reading that was pure artifact and cost several probes down the wrong path. SANITIZE now participates in the signature, so a sanitizer-only change rebuilds. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent abfac06 commit b33a4de

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

‎Makefile.cbm‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -763,11 +763,20 @@ TRE_OBJ_TEST = $(BUILD_DIR)/tre.o
763763
TRE_OBJ_TSAN = $(BUILD_DIR)/tsan_tre.o
764764
TRE_OBJ_PROD = $(BUILD_DIR)/prod_tre.o
765765

766-
# NOTE: tre.o once dropped UBSan's alignment check here. That was a real
767-
# coverage hole in a vendored regex engine we ship. Re-enabled: if the
768-
# upstream misaligns, we want the report, not silence.
766+
# tre.o keeps UBSan's alignment check OFF, and that is not a coverage
767+
# preference -- it is a portability fact. Arming it here (attempted, then
768+
# reverted after this bisect) makes the vendored TRE regex engine trap on
769+
# Windows/ARM64, where the CLANGARM64 leg builds with -fsanitize-trap and a
770+
# trap is an illegal instruction with no diagnostic: every fixture-indexing
771+
# suite died with STATUS_ILLEGAL_INSTRUCTION and no message. macOS and Linux
772+
# stay clean under the same check because Windows is LLP64 -- 32-bit long --
773+
# so TRE's struct layouts and access widths differ there and nowhere else.
774+
#
775+
# TRE is third-party code we vendor and do not modify, so the alignment
776+
# behaviour is upstream's to change; suppressing the check for this one
777+
# object is the honest scope. Everything else keeps alignment armed.
769778
$(BUILD_DIR)/tre.o: $(TRE_SRC) | $(BUILD_DIR)
770-
$(CC) $(TRE_CFLAGS) $(SANITIZE) -c -o $@ $<
779+
$(CC) $(TRE_CFLAGS) $(SANITIZE) -fno-sanitize=alignment -c -o $@ $<
771780

772781
$(BUILD_DIR)/tsan_tre.o: $(TRE_SRC) | $(BUILD_DIR)
773782
$(CC) $(TRE_CFLAGS) $(TSAN_SANITIZE) -c -o $@ $<
@@ -964,7 +973,13 @@ MAIN_SRC = src/main.c
964973
# incremental builds are unaffected. (Single-quoted: the signature may contain
965974
# the escaped quotes of -DCBM_VERSION, which are literal inside '', but must not
966975
# contain a literal single quote.)
967-
BUILD_CONFIG_SIG := TEST_SEAMS=$(TEST_SEAMS)|CFLAGS_EXTRA=$(CFLAGS_EXTRA)
976+
# SANITIZE belongs here: it changes the instrumentation compiled into every
977+
# object, so a build that only changes it MUST rebuild. Its absence made
978+
# `scripts/test.sh SANITIZE= ...` -- the documented way to get a plain build
979+
# for trap debugging -- silently re-run the previously instrumented binary,
980+
# which during this bisect produced a "crashes without sanitizers too" result
981+
# that was pure artifact and sent the investigation down the wrong path.
982+
BUILD_CONFIG_SIG := TEST_SEAMS=$(TEST_SEAMS)|CFLAGS_EXTRA=$(CFLAGS_EXTRA)|SANITIZE=$(SANITIZE)
968983
.PHONY: build-config-check
969984
build-config-check:
970985
$(BUILD_DIR)/.build-config: build-config-check | $(BUILD_DIR)

0 commit comments

Comments
 (0)