[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: lua_pushcfunction (lua 5.3) seems to be able to throw error, contrary to docs
- From: Andrew Gierth <andrew@...>
- Date: Tue, 05 Dec 2017 12:24:26 +0000
I may be misreading this, but:
5.3 docs say that lua_pushcfunction cannot throw error (it's tagged with
[-0, +1, -]).
But reading the code, it seems to be able to throw an error on this
path:
lua_pushcfunction (macro)
calls lua_pushcclosure with n==0
calls luaC_checkGC (even when n==0)
calls luaC_step
calls runafewfinalizers
calls GCTM with propagateerrors==1
calls luaD_throw to propagate an error from a finalizer
This looks like a problem in the code to me: wouldn't it make more sense
to put the luaC_checkGC call in lua_pushcclosure inside the else
clause?
But if the behavior of the code is regarded as being correct, it seems a
rather critical documentation error... I just wrote a whole lot of code
relying on the documented behavior, and got a very nasty surprise.
--
Andrew.