Fatal runtime errors for all code built by Rust 1.48 and above
Rust nightly builds have been bumped up to 1.49, and when built with this version both my live bot's code and our sample begin throwing runtime stdweb conversion errors:
RuntimeError: unreachable
at rust_panic (wasm-function[178]:1)
at _ZN3std9panicking20rust_panic_with_hook17h1347218c91d128f7E (wasm-function[170]:117)
at _ZN3std9panicking19begin_panic_handler28_$u7b$$u7b$closure$u7d$$u7d$17hfae94c93fb3d0300E (wasm-function[181]:1)
at _ZN3std10sys_common9backtrace26__rust_end_short_backtrace17hf812f49b8d150ee0E (wasm-function[180]:6)
at rust_begin_unwind (wasm-function[27]:52)
at _ZN4core9panicking9panic_fmt17h6aa2a8f84484b5f7E (wasm-function[24]:48)
at _ZN4core9panicking5panic17hc886a4cb4479b06eE (wasm-function[14]:67)
at _ZN148_$LT$stdweb..webcore..serialization..SerializedValue$u20$as$u20$core..convert..From$LT$stdweb..webcore..serialization..SerializedUntaggedF64$GT$$GT$4from17h1f45361611ee357cE (wasm-function[72]:14)
at _ZN50_$LT$T$u20$as$u20$core..convert..Into$LT$U$GT$$GT$4into17h099fb7234c614c67E (wasm-function[71]:1)
If we're unlucky, this breakage will carry down to stable like it did with #287 👎 ; probably #329 will be our way forward since stdweb isn't showing any signs of life.
maybe for now we should report that as regression as described here? https://blog.rust-lang.org/2020/10/20/regression-labels.html
I suspect the regression is in stdweb, not Rust. There isn't much we can do about that short of forking and patching stdweb, which seems very suboptimal.
A workaround is using this patch: https://github.com/koute/stdweb/issues/411#issue-748336955
A workaround is using this patch: koute/stdweb#411 (comment)
I can confirm that this works:
# append to Cargo.toml
[patch.crates-io]
stdweb = { git = 'https://github.com/arturoc/stdweb.git' }
I was able to change the rust version to 1.51.0 :smile_cat:
Which also allowed me to install a proper panic handler (although this is a bit off-topic):
pub fn halt() {
log::warn!("halting execution. run `Memory.halted = false` to continue.");
screeps::memory::root().set("halted", true);
}
fn main() {
panic::set_hook(Box::new(|panic_info| {
if let Some(location) = panic_info.location() {
log::error!(
"panic: {}:{}: {}",
location.file(),
location.line(),
panic_info
);
} else {
log::error!("panic: {}", panic_info);
}
// use this in your game loop to not execute anything if you want to stop after a panic.
screeps::memory::root().set("halted", true);
}));
}