lua-users home
lua-l archive

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

On Fri, Aug 19, 2011 at 1:36 AM, HyperHacker <> wrote:
> Right, but what if I do:
> EnterCriticalSection()
> while true do end
> ?

You mean in sandboxed code? You don't get a function like
EnterCriticalSection there.

I actually got the whole thing covered now, I think. OS functions that
should not be interrupted are simply wrapped with copcall. That way,
they execute in a new coroutine without a timeout hook.

Sandboxed code gets a special version of pcall that is like copcall,
but transfers the debug hook to the new coroutine and escalates
timeout errors back to the calling script to prevent them from being
supressed by user code.

Unless I made some logical mistake, this should solve all the problems
we discussed w/regards to critical sections and timeouts.

Regarding the "forced yield" idea (yielding inside a debug hook): I
just tried it and it seems it just doesn't work. It says "attempt to
yield across metamethod/C-call boundary". I guess entering a debug
hook is considered a C-call boundary... so there goes that idea. :(

(I don't know if I'm that sad though as I was never that fond of that
idea. But well. Would have been interesting to play with, certainly.)

Can the C-call boundary problem be worked around in some way?