[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: lua_newthread panics when out of memory!
- From: "Erik Cassel" <erik@...>
- Date: Fri, 26 Feb 2010 04:37:02 -0800
Ah, that makes sense!
I'm trying a lua_cpcall() wrapper around the entire block of code.
[mailto:email@example.com] On Behalf Of Roberto
Sent: Wednesday, February 24, 2010 1:05 PM
To: Lua list
Subject: Re: lua_newthread panics when out of memory!
> When I call lua_newthread under low-memory conditions the Lua allocator
> might fail. I've found that this causes Lua to panic.
> I think that lua_newthread should return null rather than crashing hard.
> After all, Lua was designed to work with small memory footprints.
> Is there a reason why lua_newthread can't fail gracefully? Is the internal
> state corrupted is some way that can't be recovered from?
lua_newthread behaves (or should behave) like any other API call: It
raises a regular error in case of an allocation error. What causes the
panic (probably) is that your code is running in unprotected mode, so
there is no proper error handler to get the error.