aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-12-13 10:41:17 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-12-13 10:41:17 -0300
commit0bfc572e51d9035a615ef6e9523f736c9ffa8e57 (patch)
tree218f2bb13a873becf8fa657a296c8863f7e0e466 /testes
parent1de95e97ef65632a88e08b6184bd9d1ceba7ec2f (diff)
downloadlua-0bfc572e51d9035a615ef6e9523f736c9ffa8e57.tar.gz
lua-0bfc572e51d9035a615ef6e9523f736c9ffa8e57.tar.bz2
lua-0bfc572e51d9035a615ef6e9523f736c9ffa8e57.zip
Bug: GC is not reentrant
As the GC is not reentrant, finalizers should not be able to invoke it.
Diffstat (limited to 'testes')
-rw-r--r--testes/api.lua5
-rw-r--r--testes/gc.lua6
2 files changed, 6 insertions, 5 deletions
diff --git a/testes/api.lua b/testes/api.lua
index c1bcb4b7..bd85a923 100644
--- a/testes/api.lua
+++ b/testes/api.lua
@@ -804,15 +804,14 @@ F = function (x)
804 d = nil 804 d = nil
805 assert(debug.getmetatable(x).__gc == F) 805 assert(debug.getmetatable(x).__gc == F)
806 assert(load("table.insert({}, {})"))() -- create more garbage 806 assert(load("table.insert({}, {})"))() -- create more garbage
807 collectgarbage() -- force a GC during GC 807 assert(not collectgarbage()) -- GC during GC (no op)
808 assert(debug.getmetatable(x).__gc == F) -- previous GC did not mess this?
809 local dummy = {} -- create more garbage during GC 808 local dummy = {} -- create more garbage during GC
810 if A ~= nil then 809 if A ~= nil then
811 assert(type(A) == "userdata") 810 assert(type(A) == "userdata")
812 assert(T.udataval(A) == B) 811 assert(T.udataval(A) == B)
813 debug.getmetatable(A) -- just access it 812 debug.getmetatable(A) -- just access it
814 end 813 end
815 A = x -- ressucita userdata 814 A = x -- ressurect userdata
816 B = udval 815 B = udval
817 return 1,2,3 816 return 1,2,3
818end 817end
diff --git a/testes/gc.lua b/testes/gc.lua
index 2332c939..d865cb28 100644
--- a/testes/gc.lua
+++ b/testes/gc.lua
@@ -676,11 +676,13 @@ end
676-- just to make sure 676-- just to make sure
677assert(collectgarbage'isrunning') 677assert(collectgarbage'isrunning')
678 678
679do -- check that the collector is reentrant in incremental mode 679do -- check that the collector is not reentrant in incremental mode
680 local res = true
680 setmetatable({}, {__gc = function () 681 setmetatable({}, {__gc = function ()
681 collectgarbage() 682 res = collectgarbage()
682 end}) 683 end})
683 collectgarbage() 684 collectgarbage()
685 assert(not res)
684end 686end
685 687
686 688