d1961e79fc
Integrate 182 upstream commits throughb2473e60while retaining MoonWell packaging, branding and the community ruRU pack. Upstream replaces the C Lua/mlua host with benilla-lua/benilla-mlua and the native glue screens with stock GlueXML. The update also includes the new locale/DBC/name rules, cache and interaction handling, rendering, quest log and chat behavior, including the latest quest completion and timed-quest failure fixes. Fork adaptations use the new APIs: stock Wow.ini locales remain intact, while the ruRU overlay reads column zero and retains its ruRU authentication tag and Lua identity. Russian names keep their twelve-letter policy and Unicode roster matching; fonts, spell costs, race/class labels and translated options retain real-pack regression coverage. Windows regression fixes keep the locale-default test valid under instrumented window overrides and the shader assertion independent of checkout line endings. The original C Lua 5.1 host, rebuilt fromc0630f3din an isolated directory, reproduces the complete Windows cos-sweep answer byte for byte; cos now uses platform-specific goldens. Validation on Windows: scripts/gates.sh passed all automatic gates, including real-data and no-install workspace tests, reference tables, documentation, message catalog, render-pass lint, player clippy/tests and engine boots with and without data. MoonWell player clippy also passed with -D warnings. The committed tree exactly matches the full green stamp; five vendored Kira files retain the tested checkout's line endings, with normalized contents unchanged. All three actual ruRU pack regressions passed in both builds. Fifteen test archives were restored read-only from the published client and SHA-256 checked. Each real-data/player rung skipped 31 tests because the optional addon corpus is absent (24 general, 7 Quiver). Live smoke was not run: no declared probe account; no player-account login or character creation was performed. Linux/macOS changes were not locally built.
99 lines
3.0 KiB
Rust
99 lines
3.0 KiB
Rust
//! A native holds `&mut Vm`, so safe code could put another VM or heap in place of the running
|
|
//! one, freeing the code and stack the running frames point into. The interpreter stops with a
|
|
//! panic there; it never runs on.
|
|
|
|
use benilla_lua::Vm;
|
|
|
|
fn replace_heap(vm: &mut Vm, _nargs: usize) -> benilla_lua::api::R<usize> {
|
|
vm.heap = Default::default();
|
|
Ok(0)
|
|
}
|
|
|
|
fn replace_vm(vm: &mut Vm, _nargs: usize) -> benilla_lua::api::R<usize> {
|
|
*vm = benilla_lua::new_state();
|
|
Ok(0)
|
|
}
|
|
|
|
fn run_with(native: benilla_lua::heap::NativeFn) -> String {
|
|
let mut vm = benilla_lua::new_state();
|
|
let f = vm.new_native("replace", native);
|
|
vm.set_global("replace", f);
|
|
let r = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
|
// In a protected call, inside a Lua function, with a loop after: every way on would
|
|
// read the freed frames.
|
|
vm.exec(
|
|
b"local function g() replace() local s = 0 for i = 1, 10 do s = s + i end return s end \
|
|
return pcall(g)",
|
|
b"=t",
|
|
)
|
|
}));
|
|
match r {
|
|
Ok(_) => "ran on".to_owned(),
|
|
Err(p) => p
|
|
.downcast_ref::<&str>()
|
|
.map(|s| s.to_string())
|
|
.or_else(|| p.downcast_ref::<String>().cloned())
|
|
.unwrap_or_default(),
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn a_native_that_replaces_the_heap_stops_the_vm() {
|
|
assert_eq!(
|
|
run_with(replace_heap),
|
|
"a native replaced the running Lua VM or its heap"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn a_native_that_replaces_the_vm_stops_it() {
|
|
assert_eq!(
|
|
run_with(replace_vm),
|
|
"a native replaced the running Lua VM or its heap"
|
|
);
|
|
}
|
|
|
|
/// A hook, and host code a collection inside Lua runs (a freed host closure's captures, dropped
|
|
/// through the host's `reentry`), hold the same `&mut Vm`; one that replaces it stops the VM too.
|
|
#[test]
|
|
fn a_hook_or_a_collection_that_replaces_the_vm_stops_it() {
|
|
use std::rc::Rc;
|
|
let stopped = |vm: &mut Vm, src: &[u8]| {
|
|
let r = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| vm.exec(src, b"=t")));
|
|
r.err()
|
|
.and_then(|p| p.downcast_ref::<&str>().map(|s| s.to_string()))
|
|
.unwrap_or_default()
|
|
};
|
|
let mut vm = benilla_lua::new_state();
|
|
vm.set_hook(
|
|
10,
|
|
Rc::new(|vm: &mut Vm| {
|
|
vm.heap = Default::default();
|
|
Ok(())
|
|
}),
|
|
);
|
|
assert_eq!(
|
|
stopped(
|
|
&mut vm,
|
|
b"local s = 0 for i = 1, 100 do s = s + i end return s"
|
|
),
|
|
"a native replaced the running Lua VM or its heap"
|
|
);
|
|
|
|
let mut vm = benilla_lua::new_state();
|
|
vm.reentry = Some(Rc::new(|vm: &mut Vm, f: &mut dyn FnMut()| {
|
|
*vm = benilla_lua::new_state();
|
|
f()
|
|
}));
|
|
let host: benilla_lua::heap::HostFn = Rc::new(|_: &mut Vm, _| Ok(0));
|
|
let f = vm.new_host("f", host);
|
|
vm.set_global("F", f);
|
|
assert_eq!(
|
|
stopped(
|
|
&mut vm,
|
|
b"F = nil for i = 1, 200000 do local t = {i} end return 1"
|
|
),
|
|
"a native replaced the running Lua VM or its heap"
|
|
);
|
|
}
|