aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-12-13 16:35:03 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-12-13 16:35:03 -0200
commite752d84ed8250820aa3f6a097e008de6c2ec8322 (patch)
treef1aefebbbc2f4f943944e60df8dc267240eb732d
parent86431a2f1c668844c665f9d09e246de906b511d8 (diff)
downloadlua-e752d84ed8250820aa3f6a097e008de6c2ec8322.tar.gz
lua-e752d84ed8250820aa3f6a097e008de6c2ec8322.tar.bz2
lua-e752d84ed8250820aa3f6a097e008de6c2ec8322.zip
bug: memory-allocation error when resizing a table can leave it
in an inconsistent state.
-rw-r--r--bugs29
1 files changed, 27 insertions, 2 deletions
diff --git a/bugs b/bugs
index bd4b313c..d796facb 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.157 2017/08/31 16:14:41 roberto Exp roberto $ 3683< ** $Id: bugs,v 1.158 2017/12/06 18:20:28 roberto Exp roberto $
3684--- 3684---
3685> ** $Id: bugs,v 1.157 2017/08/31 16:14:41 roberto Exp roberto $ 3685> ** $Id: bugs,v 1.158 2017/12/06 18:20:28 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---
@@ -3904,6 +3904,31 @@ patch = [[
3904} 3904}
3905 3905
3906 3906
3907Bug{
3908what = [[memory-allocation error when resizing a table can leave it
3909in an inconsistent state.]],
3910report = [[Roberto, 2017/12/08]],
3911since = [[5.0]],
3912fix = nil,
3913example = [[
3914local a = {x = 1, y = 1, z = 1}
3915a[1] = 10 -- goes to the hash part (which has 4 slots)
3916print(a[1]) --> 10
3917
3918-- assume that the 2nd memory allocation from now fails
3919pcall(rawset, a, 2, 20) -- forces a rehash
3920
3921-- a[1] now exists both in the array part (because the array part
3922-- grew) and in the hash part (because the allocation of the hash
3923-- part failed, keeping it as it was).
3924-- This makes the following traversal goes forever...
3925for k,v in pairs(a) do print(k,v) end
3926]],
3927patch = [[
3928]]
3929}
3930
3931
3907 3932
3908 3933
3909--[=[ 3934--[=[