[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: g->GCthreshold overflow, possible bug?
- From: "Cheng, Long" <long.x.cheng@...>
- Date: Mon, 13 Aug 2012 19:21:26 +0800
hi group:
Today I noticed some strange behavior in my lua application:
My application disables lua autogc and manually calls lua_gc(LUA_GCSTEP)
regularly. When memory usage exceeds 2G, each call to lua_gc(LUA_GCSTEP)
becomes a full gc cycle (retval = 1).
I managed to track down the cause of this problem to the following line
in lgc.c:
#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause)
When g->estimate exceeds 2G and gcpause remains its default value 200,
GCthreshold will overflow uint32 range.
I made the following fix and testing shows it is good:
#define setthreshold(g) (g->GCthreshold = ((long long)g->estimate/100)
* (long long)g->gcpause > MAX_LUMEM ? MAX_LUMEM : (g->estimate/100 *
g->gcpause) )
Is this a bug? Is there any known solution for this?
The lua version I used is luajit 1.1.5/lua 5.1.4 and I can not switch to 5.2
Thanks
Regards
Long