mirror of https://github.com/swig/swig.git
importtest2 did strcpy(str, "white") on its argument. The Lua char *
typemap passes lua_tostring(), a pointer into Lua's interned string
storage, so this overwrote the interned literal "black" in place: its
bytes became "white" while its cached hash stayed that of "black".
lua_pushstring() then re-interned "white" via internshrstr(), which
scans one hash bucket comparing contents with memcmp only. When the
corrupted string sat in that bucket ahead of the real "white", it was
returned instead, and since Lua compares short strings by identity the
runme's inctest.importtest2("black") == "white" was false.
Whether it bit depended on the per process string hash seed and on
string table growth, which reverses bucket chain order, so the test
failed only occasionally under Lua 5.5 in CI. Sweeping the seed with a
forced table growth reproduced it in 36 of 20000 seeds; none fail now.
Return a static buffer instead. inctest passes for all 17 target
languages configured here.
Assisted-by: Claude Code (Opus 5)
|
||
|---|---|---|
| .. | ||
| go_subdir_import | ||
| inctest | ||
| README | ||
README
This is a special directory for testcases that require inputs using subdirectories. Each subdirectory should be named after the testcase. Any desired subdirectory structure can be put under the testcase subdirectory.