Commit Graph

3 Commits

Author SHA1 Message Date
William S Fulton ae445a8f3c [Lua] Fix flaky li_std_map test caused by garbage collected Struct objects
The IntStructPtrMap and IntStructConstPtrMap sections passed newly
constructed Struct objects straight into the map and kept no Lua
reference to them. These maps store just the raw pointers, so once the
incremental collector completed a cycle the Struct objects were deleted
and the maps were left holding dangling pointers. The following value
checks then read freed memory, which sporadically failed in CI with:

  li_std_map_runme.lua:68: ispmap:get(8)

Hold the Struct objects in a Lua table for the lifetime of the maps.

Confirmed as a use-after-free with valgrind and reproducible before the
fix by lowering the collector pause with collectgarbage("setpause", 105).

Assisted-by: Claude Code (Opus 5)
2026-08-01 09:42:44 +01:00
Erez Geva d43ee445e0
Rename the near function to cmp_flt function that compare float numbers (#3490)
And move it to helpers.
Although Lua uses C floating math.
The actual used C floating functions in Lua
 might be different from the actual floating functions
 used in the original C code, which may lead to a slightly
 different floating number.
So for calculated floating numbers we should use the cmp_flt function in the assert.

Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
2026-07-09 18:27:35 +01:00
Erez Geva a1b3ca81ca More Lua tests (#3405)
- Add Lua examples
- Add and fix unused Lua tests
- Add lua_module_global complementary test of lua_no_module_global
- Add Lua test-suite runme files

Enable friends_nested and minherit inline test code for Lua via the
SWIGLUA guards.
2026-05-31 15:09:53 +01:00