tomaka / hlua

Rust library to interface with Lua
MIT License
507 stars 48 forks source link

Closures can outlive their environments #77

Closed CryZe closed 7 years ago

CryZe commented 8 years ago

All the hlua::functionxx functions take closures that can outlive their environments and cause Segfaults and all kinds of other corruptions as can be seen in this video: https://youtu.be/-0oMsyXZtwA

tomaka commented 7 years ago

Unfortunately I have no idea how to fix that.

Hlua's code is basically impl<C, L> Push<L> for C where L: Lua, C: FnMut() -> (). I don't see how to enforce the fact that C must outlive L.

CryZe commented 7 years ago

Maybe force them to have a static lifetime, just like threads do? Not sure if that's possible.

tomaka notifications@github.com schrieb am Do. 22. Dez. 2016 um 14:21:

Unfortunately I have no idea how to fix that.

Hlua's code is basically impl<C, L> Push for C where L: Lua, C: FnMut() -> ().

I don't see how to enforce the fact that C must outlive L.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tomaka/hlua/issues/77#issuecomment-268798168, or mute the thread https://github.com/notifications/unsubscribe-auth/ABYmbi5SC57HJY0KcbA2Vy9PUCOUC3sJks5rKnlGgaJpZM4Ijbyk .