fix(parser): use alias-safe Haskell arrays#1232
Conversation
Preload the shared Tree-sitter array helpers before the pinned Haskell scanner so optimized builds do not retain a stale contents pointer across realloc. Keep a compile-time signature guard to prevent regression. Fixes DeusData#1231 Signed-off-by: wargloom <wargloom@gmail.com>
|
Thanks for the very small and plausible fix. Reusing the already-vendored strict-aliasing-safe Tree-sitter array helper is the right shape, introduces no new vendor or dependency, and the head is fully green. The remaining blocker is reproduce-first coverage: no test changed, and the |
|
Thanks, and sorry for the slow acknowledgement. Queued for review. A four-line change with 28 green checks is about as reviewable as a contribution gets — nothing blocking on your side. Alias-safe Haskell arrays is a precise fix to a real parsing hazard. |
What does this PR do?
Fixes the optimized-build heap corruption in the pinned Haskell external scanner without reducing indexing parallelism.
The scanner vendors an older Tree-sitter array helper that type-puns concrete Array structs through Array(void) pointers. At -O2, the Haskell lookahead growth path can retain the old contents pointer across realloc and write into freed memory. Valgrind identified the first invalid write in advance -> take_line -> newline_lookahead -> tree_sitter_haskell_external_scanner_scan.
The Haskell grammar wrapper now preloads the repository existing strict-aliasing-safe Tree-sitter array helpers, using the shared include guard to skip the unsafe pinned copy. A C11 static assertion locks the helper signature so the unsafe implementation cannot silently return.
Fixes #1231
Validation
Checklist