decimal: introduce and use lua_pushdecimalstr()
decimal conversion to string in Lua used decimal_str() function. The function is not safe to use in preemptive context like Lua, where any attempt to push something onto the Lua stack might trigger GC, which in turn might invoke any other code. It is not safe because uses the static buffer, which is global and cyclic. Newer allocations can override the old data without any warning. The same problem was fixed for tt_uuid_str() and uuids in box.info in one of the previous commits. The patch adds a new function lua_pushdecimalstr() which does not use the static buffer. It is now used to push decimals safely on a Lua stack. Follow up #5632 Follow up #6050 Closes #6259
Showing
- changelogs/unreleased/gh-6259-static-buf-in-lua.md 5 additions, 0 deletionschangelogs/unreleased/gh-6259-static-buf-in-lua.md
- src/lua/decimal.c 13 additions, 1 deletionsrc/lua/decimal.c
- src/lua/decimal.h 3 additions, 0 deletionssrc/lua/decimal.h
- test/app-tap/gh-5632-6050-6259-gc-buf-reuse.test.lua 37 additions, 1 deletiontest/app-tap/gh-5632-6050-6259-gc-buf-reuse.test.lua
Loading
Please register or sign in to comment