From dbaad29b2a1e567efc114935a3519b7cd6b7921e Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Mon, 12 May 2025 17:01:22 +0200 Subject: [PATCH] Add Development Notes --- Development-Notes.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Development-Notes.md diff --git a/Development-Notes.md b/Development-Notes.md new file mode 100644 index 0000000..d3d0dde --- /dev/null +++ b/Development-Notes.md @@ -0,0 +1,6 @@ +## Lua's error handling breaks Rust's memory safety + +Since Lua utilizes `longjmp` for error handling and stack unwinding, any Lua error that crosses a Rust stack frame is going to lead to memory leaks from skipping `drop`s and to borrow checker constraints being broken. + +The problem is that many Lua functions create errors internally. Some of them cannot be avoided (e.g. OOM), but wherever possible, per-conditions need to be checked such that Lua does not `longjmp`. +E.g. a `lua.tostring` must be preceded by a `lua.isstring`. \ No newline at end of file