Giter Club home page Giter Club logo

Comments (7)

yongkangchen avatar yongkangchen commented on August 18, 2024

dofile "test" 改成 require "test" 不会crash

from slua.

yongkangchen avatar yongkangchen commented on August 18, 2024

还是使用 dofile "test", 把LuaState.cs中的

            string resumefunc = @"
local resume = coroutine.resume
local unpack = unpack or table.unpack
coroutine.resume=function(co,...)
    local ret={resume(co,...)}
    if not ret[1] then UnityEngine.Debug.LogError(debug.traceback(co,ret[2])) end
    return unpack(ret)
end
";

if not ret[1] then UnityEngine.Debug.LogError(debug.traceback(co,ret[2])) end
改成
if not ret[1] then print(debug.traceback(co,ret[2])) end
后不会crash

from slua.

yongkangchen avatar yongkangchen commented on August 18, 2024

环境说明:

  • 操作系统:mac os x 10.10.3
  • Unity: 4.6.4.f1
  • Slua: 0.8.1

from slua.

yongkangchen avatar yongkangchen commented on August 18, 2024

进一步查证,与LuaTimer没关系。测试代码如下:

function main()
    local co
    co = coroutine.create(function()
        dofile "test"
    end)
    coroutine.resume(co)
end

from slua.

pangweiwei avatar pangweiwei commented on August 18, 2024

我这里没有crash,但我大概知道如果真的crash的原因,也许需要在c代码层面实现dofile,类似require,只是不再检查_LOADED表。

from slua.

yongkangchen avatar yongkangchen commented on August 18, 2024

@pangweiwei 很奇怪的是,我把LuaState.cs中的

if not ret[1] then UnityEngine.Debug.LogError(debug.traceback(co,ret[2])) end 

改成

if not ret[1] then pcall(function() UnityEngine.Debug.LogError(debug.traceback(co,ret[2])) end) end

后不会crash,并且debug.traceback的错误堆栈能正常通过UnityEngine.Debug.LogError打印出来

from slua.

pangweiwei avatar pangweiwei commented on August 18, 2024

crash是应为堆栈坏了,dofile放在c代码实现是安全的。

from slua.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.