Git Product home page Git Product logo

Comments (8)

coderedart avatar coderedart commented on July 28, 2024 1

with mlua, I can vouch that loading shared libraries works. I made a dll (.so on linux) with rust (using C abi) and successfully required it with a mlua script. https://github.com/khvzak/mlua#module-mode to create native libraries.

the lua environment technically can't be sandboxed anyway :D https://github.com/amethyst/rlua#sandboxing-and-untrusted-scripts there's a lot of unsafe things happening behind the scenes between luajit + rust + lua combo. it is sort of possible with luau backend (roblox version of lua) of mlua as that is explicitly designed for sandboxing.

maybe with a wasm based lua vm or https://github.com/danii/hematita we can get proper safe sandboxing in future.

you can use (and also create) luarocks packages, but you need to manage them externally and add the path + cpath of luarocks install target location to the mlua vm.

goes without saying, but you need to match the compiled dll lua versions and the embedded vm versions. I only checked lua54 and luajit.

from bevy_mod_scripting.

makspll avatar makspll commented on July 28, 2024 1

I am planning on swapping to mlua anyway, or rather tealr for documentation generation features, so if rlua does not allow for external modules this won't be a problem for too long. I'll investigate this once i am done working on the bevy script facing API!

from bevy_mod_scripting.

lenscas avatar lenscas commented on July 28, 2024 1

May I suggest another name for that feature? Considering that enabling it presumably also enables the debug module. It is probably also good if the feature name itself makes it clear that ub can happen if it is enabled.

unsafe_lua_instance at least makes the fact that it uses unsafe clear but stays a bit vague. Though that might be a good thing to hopefully get people to read the docs so they know why it is unsafe?

from bevy_mod_scripting.

makspll avatar makspll commented on July 28, 2024

Hi,
I remember trying to import some other lua files from the scripts folder, and if i remember correctly that might work, but i am not sure about luarocks packages,

I would post an issue directly on rlua's repo since I basically just host the scripts directly with their library, so if it's possible there it's possible here!

from bevy_mod_scripting.

lenscas avatar lenscas commented on July 28, 2024

both mlua and rlua don't allow loading C libraries by default. They also don't allow loading the debug module by default.

You can enable both of them to allow this, but this requires unsafe functions to create the lua instance as both C libraries and the debug module can result in UB due to circumventing Rust's borrow rules and/or messing with state that mlua and rlua depend on.

So, in both cases it is less about sandboxing, but more as an attempt to make sure that no UB happens through their safe api. I believe there is an issue on rlua about it, questioning if this design is not more harmful than useful.

from bevy_mod_scripting.

makspll avatar makspll commented on July 28, 2024

Hmm in this case I might put that functionality behind a feature to make it opt-in. Thanks for the info @lenscas!

from bevy_mod_scripting.

makspll avatar makspll commented on July 28, 2024

It's now possible to enable the unsafe mlua contexts with the lua_modules feature

from bevy_mod_scripting.

makspll avatar makspll commented on July 28, 2024

That's probably a good idea, i will name it unsafe_lua_modules though to imply clearly what functionality is enabled with the feature

from bevy_mod_scripting.

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.