[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: 答复: [ 5.4 work2 ] Stack overflow causes crash
- From: Andrew Gierth <andrew@...>
- Date: Fri, 21 Dec 2018 16:41:21 +0000
>>>>> "Andrew" == Andrew Gierth <andrew@tao11.riddles.org.uk> writes:
Egor> Lua 5.4_work2(32-bit)
Egor> Host application crashes:
Egor> Lua 5.4_work2(64-bit)
Andrew> This suggests you're running with a stack size limit on the
Andrew> close order of 16MB, perhaps? The default buffer size is based
Andrew> on sizeof(void*) amongst other factors, so the 32-bit build is
Andrew> probably using about 12MB of stack for that code and the 64-bit
Andrew> build around 20MB.
My estimates were a bit off, I think I forgot to count increments of the
C call depth by the interpreter (i.e. each recursion through gsub is
presumably incrementing the call depth twice for each buffer on the
stack, not once).
Using the code currently at github.com/lua/lua master branch, and
instrumenting the stack depth error to actually report the measured
depth, here's some actual numbers I get. The test cases are:
"lua" : local function f() f() return 1 end f()
"gsub": local function f(s) s:gsub(".", f) return "x" end f("foo")
"conc": print(setmetatable({},{__index=function(t,i) table.concat(t,"",1,1) end})[1])
"fmt" : print(setmetatable({},{__tostring=function(t) string.format("%s",t) end}))
freebsd, clang 3.9.1, -O2, 64-bit:
lua: C stack overflow at call depth 2200, stack 317505 bytes
gsub: C stack overflow at call depth 2200, stack 10120449 bytes
conc: C stack overflow at call depth 2200, stack 9540737 bytes
fmt: C stack overflow at call depth 2200, stack 9585121 bytes
freebsd, clang 3.9.1, -O2, 32-bit:
lua: C stack overflow at call depth 2200, stack 2005217 bytes (!)
gsub: C stack overflow at call depth 2200, stack 6045857 bytes
conc: C stack overflow at call depth 2200, stack 5817553 bytes
fmt: C stack overflow at call depth 2200, stack 5812481 bytes
freebsd, clang 3.9.1, -O0, 64-bit:
lua: C stack overflow at call depth 2200, stack 7000037 bytes
gsub: C stack overflow at call depth 2200, stack 13728581 bytes
conc: C stack overflow at call depth 2200, stack 13342341 bytes
fmt: C stack overflow at call depth 2200, stack 13366037 bytes
freebsd, clang 3.9.1, -O0, 32-bit:
lua: C stack overflow at call depth 2200, stack 6718493 bytes
gsub: C stack overflow at call depth 2200, stack 8765165 bytes
conc: C stack overflow at call depth 2200, stack 8633597 bytes
fmt: C stack overflow at call depth 2200, stack 8670309 bytes
freebsd, gcc8, -O2, 64-bit:
lua: C stack overflow at call depth 2200, stack 528425 bytes
gsub: C stack overflow at call depth 2200, stack 10225961 bytes
conc: C stack overflow at call depth 2200, stack 9593545 bytes
fmt: C stack overflow at call depth 2200, stack 9690505 bytes
freebsd, gcc6, -O2, 64-bit:
lua: C stack overflow at call depth 2200, stack 528409 bytes
gsub: C stack overflow at call depth 2200, stack 10208377 bytes
conc: C stack overflow at call depth 2200, stack 9593529 bytes
fmt: C stack overflow at call depth 2200, stack 9690489 bytes
freebsd, clang 6.0.1, -O2, 64-bit:
lua: C stack overflow at call depth 2200, stack 422977 bytes
gsub: C stack overflow at call depth 2200, stack 10173217 bytes
conc: C stack overflow at call depth 2200, stack 9540801 bytes
fmt: C stack overflow at call depth 2200, stack 9690545 bytes
freebsd, clang 6.0.1, -O2, 32-bit:
lua: C stack overflow at call depth 2200, stack 2110725 bytes
gsub: C stack overflow at call depth 2200, stack 6098661 bytes
conc: C stack overflow at call depth 2200, stack 5852789 bytes
fmt: C stack overflow at call depth 2200, stack 5900389 bytes
(I'm not set up to do 32-bit tests with gcc)
Those are bigger differences than I expected for both 32-bit vs 64-bit,
and for clang39 vs clang60 vs gcc.
--
Andrew.