aboutsummaryrefslogtreecommitdiff
path: root/bugs
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-08-31 13:14:41 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-08-31 13:14:41 -0300
commit029d269f4d1afd0e9ea0f889eb3e65a7f0fab0f9 (patch)
tree3a036d990b69013a83df795117b3583abbacfb96 /bugs
parentac65bab25f1eaaf70e1826a6937a74b3a55b521b (diff)
downloadlua-029d269f4d1afd0e9ea0f889eb3e65a7f0fab0f9.tar.gz
lua-029d269f4d1afd0e9ea0f889eb3e65a7f0fab0f9.tar.bz2
lua-029d269f4d1afd0e9ea0f889eb3e65a7f0fab0f9.zip
bug: dead keys with nil values can stay in weak tables
Diffstat (limited to 'bugs')
-rw-r--r--bugs38
1 files changed, 36 insertions, 2 deletions
diff --git a/bugs b/bugs
index 8761cb63..f3caeec2 100644
--- a/bugs
+++ b/bugs
@@ -3680,9 +3680,9 @@ It needs an "interceptor" 'memcmp' function that continues
3680reading memory after a difference is found.]], 3680reading memory after a difference is found.]],
3681patch = [[ 3681patch = [[
36822c2 36822c2
3683< ** $Id: bugs,v 1.155 2017/07/27 13:55:38 roberto Exp roberto $ 3683< ** $Id: bugs,v 1.156 2017/08/12 13:12:42 roberto Exp roberto $
3684--- 3684---
3685> ** $Id: bugs,v 1.155 2017/07/27 13:55:38 roberto Exp roberto $ 3685> ** $Id: bugs,v 1.156 2017/08/12 13:12:42 roberto Exp roberto $
3686263c263,264 3686263c263,264
3687< for (option = LUA_STRFTIMEOPTIONS; *option != '\0'; option += oplen) { 3687< for (option = LUA_STRFTIMEOPTIONS; *option != '\0'; option += oplen) {
3688--- 3688---
@@ -3837,6 +3837,40 @@ patch = [[
3837} 3837}
3838 3838
3839 3839
3840Bug{
3841what = [[dead keys with nil values can stay in weak tables]],
3842report = [[云风 Cloud Wu, 2017/08/15]],
3843since = [[5.2]],
3844fix = nil,
3845example = [[
3846-- The following chunk, under a memory checker like valgrind,
3847-- produces a memory access violation.
3848
3849local a = setmetatable({}, {__mode = 'kv'})
3850
3851a['ABCDEFGHIJKLMNOPQRSTUVWXYZ' .. 'abcdefghijklmnopqrstuvwxyz'] = {}
3852a[next(a)] = nil
3853collectgarbage()
3854print(a['BCDEFGHIJKLMNOPQRSTUVWXYZ' .. 'abcdefghijklmnopqrstuvwxyz'])
3855]],
3856patch = [[
3857--- lgc.c 2016/12/22 13:08:50 2.215
3858+++ lgc.c 2017/08/31 16:08:23
3859@@ -643,8 +643,9 @@
3860 for (n = gnode(h, 0); n < limit; n++) {
3861 if (!ttisnil(gval(n)) && (iscleared(g, gkey(n)))) {
3862 setnilvalue(gval(n)); /* remove value ... */
3863- removeentry(n); /* and remove entry from table */
3864 }
3865+ if (ttisnil(gval(n))) /* is entry empty? */
3866+ removeentry(n); /* remove entry from table */
3867 }
3868 }
3869 }
3870]]
3871}
3872
3873
3840 3874
3841 3875
3842--[=[ 3876--[=[