ITADN

Fix aarch64-linux memory corruption

#151Pull Requestscherna 创建于 2025-11-03
S
schernacommented
This is an attempt to fix the memory corruption seen on aarch64-linux ([in issue 144](https://github.com/tree-sitter/tree-sitter-haskell/issues/144)). On aarch64-linux, `tree-sitter test` would crash, while `tree-sitter test --debug-build` would pass (except for one test, `varsym: error: carrow:`, which would fail no matter what, but with a failure seemingly unrelated to the memory corruption). With this change, `tree-sitter test` passes all tests but `varsym: error: carrow:` and does not exhibit any crashes. Claude helped me track down that the discrepancy between `--debug-build` and not is that `--debug-build` uses lower optimization flags- `-O0` and `-O1` are fine, but `-O2` causes the crash. Claude then identified the change to `scanner.c` as a potential fix (the remainder of the diff is generated by `tree-sitter generate --build`). I can't say I fully understand it, but seemingly at higher optimization levels, `PEEK` might be incremented simultaneously with `array_push` leading to out-of-bounds memory access?
合并状态:未合并 5 条评论