[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: LuaJIT-2 signedness bug in collectgarbage('count')
- From: Tony Finch <dot@...>
- Date: Mon, 25 Oct 2010 13:46:39 +0100
This is on 32 bit Linux:
$ ./src/luajit -e 'local t = nil; for n = 1, 38347490 do t = { t }; end; print(collectgarbage("count"))'
2097151.9697266
$ ./src/luajit -e 'local t = nil; for n = 1, 38347491 do t = { t }; end; print(collectgarbage("count"))'
-2097151.9755859
I removed the (int32_t) cast from collectgarbage to fix the problem.
$ ./src/luajit -e 'local t = nil; for n = 1, 38347491 do t = { t }; end; print(collectgarbage("count"))'
2097152.0244141
Tony.
--
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
HUMBER THAMES DOVER WIGHT PORTLAND: NORTH BACKING WEST OR NORTHWEST, 5 TO 7,
DECREASING 4 OR 5, OCCASIONALLY 6 LATER IN HUMBER AND THAMES. MODERATE OR
ROUGH. RAIN THEN FAIR. GOOD.
diff --git a/src/lib_base.c b/src/lib_base.c
index 8f63eff..0a13f36 100644
--- a/src/lib_base.c
+++ b/src/lib_base.c
@@ -359,7 +359,7 @@ LJLIB_CF(collectgarbage)
"\4stop\7restart\7collect\5count\1\377\4step\10setpause\12setstepmul");
int32_t data = lj_lib_optint(L, 2, 0);
if (opt == LUA_GCCOUNT) {
- setnumV(L->top, cast_num((int32_t)G(L)->gc.total)/1024.0);
+ setnumV(L->top, cast_num(G(L)->gc.total)/1024.0);
} else {
int res = lua_gc(L, opt, data);
if (opt == LUA_GCSTEP)