mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Do not call message handler in xpcall if allocation error
This commit is contained in:
parent
be52bd91e4
commit
99ab30cf04
3 changed files with 19 additions and 2 deletions
|
@ -550,8 +550,8 @@ int luaD_pcall(lua_State* L, Pfunc func, void* u, ptrdiff_t old_top, ptrdiff_t e
|
|||
int status = luaD_rawrunprotected(L, func, u);
|
||||
if (status != 0)
|
||||
{
|
||||
// call user-defined error function (used in xpcall)
|
||||
if (ef)
|
||||
// call user-defined error function (used in xpcall) except if allocation error
|
||||
if (ef && status != LUA_ERRMEM)
|
||||
{
|
||||
// if errfunc fails, we fail with "error in error handling"
|
||||
if (luaD_rawrunprotected(L, callerrfunc, restorestack(L, ef)) != 0)
|
||||
|
|
|
@ -1078,6 +1078,11 @@ TEST_CASE("ExceptionObject")
|
|||
ExceptionResult result = captureException(L, "large_allocation_error");
|
||||
CHECK(result.exceptionGenerated);
|
||||
}
|
||||
|
||||
{
|
||||
ExceptionResult result = captureException(L, "large_allocation_error_without_handler");
|
||||
CHECK(result.exceptionGenerated);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -32,4 +32,16 @@ function large_allocation_error()
|
|||
table.create(1000000)
|
||||
end
|
||||
|
||||
function large_allocation_error_without_handler()
|
||||
-- Create a table that will require more memory than the test's memory
|
||||
-- allocator will allow.
|
||||
local msgh_called = false
|
||||
local ok, err = xpcall(table.create, function() msgh_called = true end, 1000000)
|
||||
-- Check that message handler was not called for memory allocation error
|
||||
if not ok and not msgh_called then
|
||||
-- Propagate error
|
||||
error(err)
|
||||
end
|
||||
end
|
||||
|
||||
return('OK')
|
||||
|
|
Loading…
Add table
Reference in a new issue