summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2016-07-19 14:12:07 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2016-07-19 14:12:07 -0300
commitfc6b32bcaaf486beeffd35af44932a53f44d1c65 (patch)
tree170fba188c75ebbda8eb5458755222592de68a42
parentde96e26afc690957a1b14380ea589c10b9b9e162 (diff)
downloadlua-fc6b32bcaaf486beeffd35af44932a53f44d1c65.tar.gz
lua-fc6b32bcaaf486beeffd35af44932a53f44d1c65.tar.bz2
lua-fc6b32bcaaf486beeffd35af44932a53f44d1c65.zip
bug: Lua can generate wrong code in functions with too many constants
-rw-r--r--bugs28
-rw-r--r--lcode.c9
2 files changed, 32 insertions, 5 deletions
diff --git a/bugs b/bugs
index 4dc02d4b..0bb1ed35 100644
--- a/bugs
+++ b/bugs
@@ -3652,9 +3652,9 @@ It needs an "interceptor" 'memcmp' function that continues
3652reading memory after a difference is found.]], 3652reading memory after a difference is found.]],
3653patch = [[ 3653patch = [[
36542c2 36542c2
3655< ** $Id: loslib.c,v 1.64 2016/04/18 13:06:55 roberto Exp roberto $ 3655< ** $Id: bugs,v 1.149 2016/07/15 17:24:09 roberto Exp roberto $
3656--- 3656---
3657> ** $Id: loslib.c,v 1.64 2016/04/18 13:06:55 roberto Exp $ 3657> ** $Id: bugs,v 1.149 2016/07/15 17:24:09 roberto Exp roberto $
3658263c263,264 3658263c263,264
3659< for (option = LUA_STRFTIMEOPTIONS; *option != '\0'; option += oplen) { 3659< for (option = LUA_STRFTIMEOPTIONS; *option != '\0'; option += oplen) {
3660--- 3660---
@@ -3664,6 +3664,30 @@ patch = [[
3664} 3664}
3665 3665
3666 3666
3667Bug{
3668what = [[Lua can generate wrong code in functions with too many constants]],
3669report = [[Marco Schöpl, 2016/07/17]],
3670since = [[5.3.3]],
3671fix = nil,
3672example = [[See http://lua-users.org/lists/lua-l/2016-07/msg00303.html]],
3673patch = [[
3674--- lcode.c 2016/06/20 19:12:46 2.110
3675+++ lcode.c 2016/07/18 15:43:41
3676@@ -1018,8 +1018,8 @@
3677 */
3678 static void codebinexpval (FuncState *fs, OpCode op,
3679 expdesc *e1, expdesc *e2, int line) {
3680- int rk1 = luaK_exp2RK(fs, e1); /* both operands are "RK" */
3681- int rk2 = luaK_exp2RK(fs, e2);
3682+ int rk2 = luaK_exp2RK(fs, e2); /* both operands are "RK" */
3683+ int rk1 = luaK_exp2RK(fs, e1);
3684 freeexps(fs, e1, e2);
3685 e1->u.info = luaK_codeABC(fs, op, 0, rk1, rk2); /* generate opcode */
3686 e1->k = VRELOCABLE; /* all those operations are relocatable */
3687]]
3688}
3689
3690
3667--[=[ 3691--[=[
3668Bug{ 3692Bug{
3669what = [[ ]], 3693what = [[ ]],
diff --git a/lcode.c b/lcode.c
index 88a72df9..8bc85408 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 2.109 2016/05/13 19:09:21 roberto Exp roberto $ 2** $Id: lcode.c,v 2.110 2016/06/20 19:12:46 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -1015,11 +1015,14 @@ static void codeunexpval (FuncState *fs, OpCode op, expdesc *e, int line) {
1015** (everything but logical operators 'and'/'or' and comparison 1015** (everything but logical operators 'and'/'or' and comparison
1016** operators). 1016** operators).
1017** Expression to produce final result will be encoded in 'e1'. 1017** Expression to produce final result will be encoded in 'e1'.
1018** Because 'luaK_exp2RK' can free registers, its calls must be
1019** in "stack order" (that is, first on 'e2', which may have more
1020** recent registers to be released).
1018*/ 1021*/
1019static void codebinexpval (FuncState *fs, OpCode op, 1022static void codebinexpval (FuncState *fs, OpCode op,
1020 expdesc *e1, expdesc *e2, int line) { 1023 expdesc *e1, expdesc *e2, int line) {
1021 int rk1 = luaK_exp2RK(fs, e1); /* both operands are "RK" */ 1024 int rk2 = luaK_exp2RK(fs, e2); /* both operands are "RK" */
1022 int rk2 = luaK_exp2RK(fs, e2); 1025 int rk1 = luaK_exp2RK(fs, e1);
1023 freeexps(fs, e1, e2); 1026 freeexps(fs, e1, e2);
1024 e1->u.info = luaK_codeABC(fs, op, 0, rk1, rk2); /* generate opcode */ 1027 e1->u.info = luaK_codeABC(fs, op, 0, rk1, rk2); /* generate opcode */
1025 e1->k = VRELOCABLE; /* all those operations are relocatable */ 1028 e1->k = VRELOCABLE; /* all those operations are relocatable */