lua-users home
lua-l archive

Re: silent hang - can anyone explain?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tuesday 16, David Collier wrote:
> I mistakenly wrote:
> 
> for charIndex = startIndex, #payLoad
> do
> local char = payLoad:subs(charIndex, charIndex)
> 
> of course it should have been sub()
> 
> my program silently hung - is this an expected consequence of this
> sort of misspelling?
Lua might be doing a full GC before printing the error. Run the 
program under a debugger and when it hangs pause it and check the 
stack trace. The hang could be cause by some __gc function.
A user of my lua-zmq bindings ran into a similar hang [1]. The hang 
happened because two objects where not being closed in the correct 
order. One object still had a live reference, but the other didn't.
An easy way to check is to wrap your main script inside a pcall()
print(pcall(function(...) -- first line
-- Lua code for your main script here.
end, ...)) -- last line
1. https://github.com/Neopallium/lua-zmq/issues/32
-- 
Robert G. Jakabosky

AltStyle によって変換されたページ (->オリジナル) /