c++ - using Lua
- Eduardo Nunes (46/46) May 09 2003 Hi,
- Luna Kid (6/11) May 12 2003 Could you please notify me, too, if this gets settled?
Hi, Does anyone have compile/use Lua-5.0 package with DMC ? When compiling Lua with switches (-o or -o+all), I think the compiler(beta v834) produces wrong code (win32 code). It's fine without optimization and with other compilers. I can't reproduce the problem outside Lua. so the 'smallest exemples', it's not that small :-( http://www.sky3d.com/bug1.zip (~82k) Only need to unzip to a directory and run smake. The problem lies in file lvm.c, line 328, function luaV_concat. /*--- begin code ---*/ while (n < total && tostring(L, top-n-1)) { /* collect total length */ tl += tsvalue(top-n-1)->tsv.len; n++; } /*--- end code ---*/ tl compute the length of all strings, but in the 'while' compiled code, tl don't have the correct value. i.e., the code loops the same amount of times and in the same manner as in the unoptimized code, but at exit, the tl value isn't the same. tl is not in memory. I think tl is assign to a register, but none have the correct tl value inside the loop. as result, the destination string will be allocate with the wrong size value. (luaZ_openspace will call realloc(NULL, tl)) /*--- begin code ---*/ buffer = luaZ_openspace(L, &G(L)->buff, tl); tl = 0; for (i=n; i>0; i--) { /* concat all strings */ size_t l = tsvalue(top-i)->tsv.len; memcpy(buffer+tl, svalue(top-i), l); tl += l; } /*--- end code --*/ and will write pass end of this buffer, corrupting the heap and crash the any program, down the road. Looks like a register allocation / assignment problem, it's very hard to reproduce the register pressure up to this point in source code, to isolate no a very small example. any help ? Thanks. Eduardo Nunes edfpn hotmail.com
May 09 2003
Could you please notify me, too, if this gets settled? (I compiled Lua 5.0 with DMC but not run it much yet.) Thanks, Sz. "Eduardo Nunes" <edfpn hotmail.com> wrote in message news:b9fv71$2uc5$1 digitaldaemon.com...Hi, Does anyone have compile/use Lua-5.0 package with DMC ? When compiling Lua with switches (-o or -o+all), I think the compiler(beta v834) produces wrong code (win32 code).
May 12 2003