diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-08-30 12:51:12 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-08-30 12:51:12 -0300 |
commit | 4f292d753c892e705b6d1796d72758cdd4d49765 (patch) | |
tree | 98f2d29ad6401e97865e1002ea4b1036751b6882 | |
parent | 26629d0af16e8e7938cfb2f8c4c0ad70a027442c (diff) | |
download | lua-4f292d753c892e705b6d1796d72758cdd4d49765.tar.gz lua-4f292d753c892e705b6d1796d72758cdd4d49765.tar.bz2 lua-4f292d753c892e705b6d1796d72758cdd4d49765.zip |
bug: GC can collect a long string still in use during parser
-rw-r--r-- | bugs | 39 |
1 files changed, 37 insertions, 2 deletions
@@ -1880,8 +1880,8 @@ patch = [[ | |||
1880 | +++ lundump.c 2008/04/04 19:51:41 2.7.1.4 | 1880 | +++ lundump.c 2008/04/04 19:51:41 2.7.1.4 |
1881 | @@ -1,5 +1,5 @@ | 1881 | @@ -1,5 +1,5 @@ |
1882 | /* | 1882 | /* |
1883 | -** $Id: bugs,v 1.124 2013/05/16 16:03:50 roberto Exp roberto $ | 1883 | -** $Id: bugs,v 1.125 2013/07/05 18:02:28 roberto Exp roberto $ |
1884 | +** $Id: bugs,v 1.124 2013/05/16 16:03:50 roberto Exp roberto $ | 1884 | +** $Id: bugs,v 1.125 2013/07/05 18:02:28 roberto Exp roberto $ |
1885 | ** load precompiled Lua chunks | 1885 | ** load precompiled Lua chunks |
1886 | ** See Copyright Notice in lua.h | 1886 | ** See Copyright Notice in lua.h |
1887 | */ | 1887 | */ |
@@ -3100,6 +3100,41 @@ patch = [[ | |||
3100 | ]] | 3100 | ]] |
3101 | } | 3101 | } |
3102 | 3102 | ||
3103 | Bug{ | ||
3104 | what = [[GC can collect a long string still in use during parser]], | ||
3105 | report = [[Roberto, 2013/08/30]], | ||
3106 | since = [[5.2]], | ||
3107 | fix = nil, | ||
3108 | example = [[This bug is very difficult to happen (and to reproduce), | ||
3109 | because it depends on the GC running in a very specific way when | ||
3110 | parsing a source code with long (larger than 40 characters) identifiers.]], | ||
3111 | patch = [[ | ||
3112 | --- ltable.h 2013/04/12 18:48:47 2.16.1.1 | ||
3113 | +++ ltable.h 2013/08/30 15:34:24 | ||
3114 | @@ -18,4 +18,8 @@ | ||
3115 | #define invalidateTMcache(t) ((t)->flags = 0) | ||
3116 | |||
3117 | +/* returns the key, given the value of a table entry */ | ||
3118 | +#define keyfromval(v) \ | ||
3119 | + (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) | ||
3120 | + | ||
3121 | |||
3122 | LUAI_FUNC const TValue *luaH_getint (Table *t, int key); | ||
3123 | |||
3124 | --- llex.c 2013/04/12 18:48:47 2.63.1.1 | ||
3125 | +++ llex.c 2013/08/30 15:34:59 | ||
3126 | @@ -134,4 +134,7 @@ | ||
3127 | luaC_checkGC(L); | ||
3128 | } | ||
3129 | + else { /* string already present */ | ||
3130 | + ts = rawtsvalue(keyfromval(o)); /* re-use value previously stored */ | ||
3131 | + } | ||
3132 | L->top--; /* remove string from stack */ | ||
3133 | return ts; | ||
3134 | ]] | ||
3135 | } | ||
3136 | ]=] | ||
3137 | |||
3103 | 3138 | ||
3104 | --[=[ | 3139 | --[=[ |
3105 | Bug{ | 3140 | Bug{ |