diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-13 16:35:03 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-12-13 16:35:03 -0200 |
| commit | e752d84ed8250820aa3f6a097e008de6c2ec8322 (patch) | |
| tree | f1aefebbbc2f4f943944e60df8dc267240eb732d /bugs | |
| parent | 86431a2f1c668844c665f9d09e246de906b511d8 (diff) | |
| download | lua-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.
Diffstat (limited to 'bugs')
| -rw-r--r-- | bugs | 29 |
1 files changed, 27 insertions, 2 deletions
| @@ -3680,9 +3680,9 @@ It needs an "interceptor" 'memcmp' function that continues | |||
| 3680 | reading memory after a difference is found.]], | 3680 | reading memory after a difference is found.]], |
| 3681 | patch = [[ | 3681 | patch = [[ |
| 3682 | 2c2 | 3682 | 2c2 |
| 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 $ |
| 3686 | 263c263,264 | 3686 | 263c263,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 | ||
| 3907 | Bug{ | ||
| 3908 | what = [[memory-allocation error when resizing a table can leave it | ||
| 3909 | in an inconsistent state.]], | ||
| 3910 | report = [[Roberto, 2017/12/08]], | ||
| 3911 | since = [[5.0]], | ||
| 3912 | fix = nil, | ||
| 3913 | example = [[ | ||
| 3914 | local a = {x = 1, y = 1, z = 1} | ||
| 3915 | a[1] = 10 -- goes to the hash part (which has 4 slots) | ||
| 3916 | print(a[1]) --> 10 | ||
| 3917 | |||
| 3918 | -- assume that the 2nd memory allocation from now fails | ||
| 3919 | pcall(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... | ||
| 3925 | for k,v in pairs(a) do print(k,v) end | ||
| 3926 | ]], | ||
| 3927 | patch = [[ | ||
| 3928 | ]] | ||
| 3929 | } | ||
| 3930 | |||
| 3931 | |||
| 3907 | 3932 | ||
| 3908 | 3933 | ||
| 3909 | --[=[ | 3934 | --[=[ |
