English 中文(简体)
预防卢阿 in
原标题:Prevent Lua infinite loop
  • 时间:2012-04-27 14:01:01
  •  标签:
  • c#
  • lua

我利用卢阿接口在我的C#方案中得到卢阿支持,如果用户提出像这种守则一样的守则,工人的read子就会冻结。

while true do end

我可以找到一种办法,以发现fin是否正在运行,但我需要一种从工人的read子中退出多环方法的冰原。 任何想法?

编辑:@kikito, 令人不解。 我面临的问题是,我找不到一种杀人方法的干净方法,它像卢阿接口主类别(Lua)一样,有一些固定的依赖性,因为如果我做的话,lua.Close();,就我而言,它将放弃多星方法,但次,我会发现一个卢阿(Lua)级的旋转栏;)。

edit: A feature branch showing my .Close code https://github.com/AndersMalmgren/FreePIE/tree/detect-and-recover-infite-lua-loop

问题回答

Sandboxing Lua

设置栅栏不足以防止意外浪费资源。

s=(a ):rep (2000)0:match ( -b )

www.un.org/spanish/ecosoc 对《卢阿法典》的一部分施加时间/历史限制的唯一可靠途径是让卢阿译员在自己的过程中工作,并使贵办监督这一进程。

Lua的冰箱是,你获得了任何复杂的、依赖性许可,用于沙箱:你只限制时间和记忆(合理;窗户有, Unix has ulimits-related:

Recovering from errors in sandboxed code

你可以处理几乎一切问题(除违反时间/期限外),而不打听你的翻译: 仅简单地总结在;如果你要求任何可能失败的Lua-API功能,你需要将其总结在你可以调换的职能范围内(或设置Lua panic功能,从那里处理)。


[我不想让人们在这种read子上屈服于假定这种 de。 固,是沙箱的足够, st流不会让我评论(yet)]。

在tine路和每 lo路结束时,只使用<>Yield 回报率<0>/code>,以等待一个框架(使工人准备被处决)。

如何确定一条线? 我不知道在C#中是可能的,但在原来的C lua是可能的。

Is yor loop detector already run in different C# task?

  • If yes, use C# variable with C# hook. In this case your loop detector set and hool check C# variable like terminateLua and throw lua error (it should be possible).
  • If no, and you detect loop on lua side (also using hooks?), set lua variable (make it upvalue to prevent user tricks) and also throw error.

重要的是,在你真正确信完成你的任务之前,不要重开这一变量(即C#或lua),因为用户可以通过<条码>的电话<<<<<<>/代码>发现你的错误并试图处理。

如果你想发现仍有漏洞,你就可以这样做。

local detect = false

detect == true

goal = 5
star = 0

function loop()
   while detect == true do
       print("Still running")
   else
       print("Loop stopped running")
   end
end

Spawn(loop)

while true do
   if star > goal then
      detect = false
   end
end

产出如下:

Still running
Still running
Still running
Still running
Still running
Loop stopped running




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签