Skip to content

Commit bb4af38

Browse files
author
Martin Vogel
committed
smoke: index a large templated C++ header to reproduce the #424 prod crash
The C++ heap-corruption crash only manifests in the production binary (MI_OVERRIDE=1), so the smoke job (which runs the prod binary) is where it reproduces — most reliably on Windows. A ~10k-line templated header exercises the parse-churn path; indexing it must succeed.
1 parent 0d2da15 commit bb4af38

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎scripts/smoke-test.sh‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,29 @@ database:
9696
host: localhost
9797
YAMLEOF
9898

99+
# C++ crash reproduction (#424): a large, templated C++ header. The vendored
100+
# tree-sitter runtime previously corrupted the heap and SEGV'd mid-parse on
101+
# large templated C++ in the PRODUCTION build (MI_OVERRIDE=1) — most reliably on
102+
# Windows static-MinGW, where ts_malloc/ts_free could resolve to different
103+
# allocators. Generating a header with heavy parse churn exercises that path;
104+
# the prod binary must index it without crashing (status must be "indexed").
105+
python3 - "$TMPDIR/src/big_templated.hpp" << 'GENEOF'
106+
import sys
107+
with open(sys.argv[1], "w") as f:
108+
f.write("#include <cstddef>\nnamespace repro {\n")
109+
for i in range(1500):
110+
f.write(
111+
"template <typename T> struct Box{0} {{\n"
112+
" T value;\n"
113+
" bool operator<(const Box{0} &o) const {{ return value < o.value; }}\n"
114+
" bool operator==(const Box{0} &o) const {{ return value == o.value; }}\n"
115+
" bool operator>(const Box{0} &o) const {{ return o.value < value; }}\n"
116+
" T get() const {{ return value; }}\n"
117+
"}};\n".format(i)
118+
)
119+
f.write("}\n")
120+
GENEOF
121+
99122
# Index
100123
RESULT=$(cli index_repository "{\"repo_path\":\"$TMPDIR\"}")
101124
echo "$RESULT"

0 commit comments

Comments
 (0)