jazzdotdev / jazz

The Scripting Engine that Combines Speed, Safety, and Simplicity
Apache License 2.0
147 stars 11 forks source link

Crashing Issue when extending from unexisting template #214

Open LuisReyes98 opened 5 years ago

LuisReyes98 commented 5 years ago

Issue

Torchbear crashes without giving a proper error message when it extends from a template that doesn't exist. example in the linked repository

https://github.com/LuisReyes98/found-patterns-theme/tree/crashing_error_in_templeate_searching

LuisReyes98 commented 5 years ago

name = 'torchbear' operating_system = 'unix:Ubuntu' crate_version = '0.11.2' explanation = ''' Panic occurred in file '/home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/tera-0.11.20/src/renderer/processor.rs' at line 774 ''' method = 'Panic' backtrace = ''' stack backtrace: 0: backtrace::backtrace::trace_unsynchronized::h82ffbb043fdb3a9b (0xe96b86) 1: backtrace::capture::Backtrace::create::h55f75705b5325feb (0xe95b47) 2: backtrace::capture::Backtrace::new::h9064988ae880e202 (0xe95a6d) 3: human_panic::report::Report::new::h68f5dc73b9d84d7f (0xdfc772) 4: human_panic::handle_dump::h6bbbedd2aa51f4dd (0xdfbca7) 5: torchbear_lib::ApplicationBuilder::start::{{closure}}::h3f59368e3b3afaf0 (0x46944b) 6: std::panicking::rust_panic_with_hook::h781594332e68f14e (0xf1f046) at libstd/panicking.rs:480 7: std::panicking::continue_panic_fmt::h986a35a447ed28cf (0xf1eb91) at libstd/panicking.rs:390 8: std::panicking::begin_panic_fmt::h788685a06248af37 (0xf1eade) at libstd/panicking.rs:345 9: tera::renderer::processor::Processor::render_node::h41d643a66743d1c0 (0xa678ef) 10: tera::renderer::processor::Processor::render_body::h1421c7a3882600ca (0xa5b77e) 11: tera::renderer::processor::Processor::render_node::h41d643a66743d1c0 (0xa6617f) 12: tera::renderer::processor::Processor::render_body::h1421c7a3882600ca (0xa5b77e) 13: tera::renderer::processor::Processor::render_node::h41d643a66743d1c0 (0xa65d6b) 14: tera::renderer::processor::Processor::render::h2d65b2d8f0a71243 (0xa687e2) 15: tera::renderer::Renderer::render::hce94de10ca52b359 (0x9fc2ac) 16: tera::tera::Tera::render::h7d51d7d850873143 (0x5eb4f2) 17: <rlua::lua::StaticUserDataMethods<'lua, T>>::box_method::{{closure}}::h374ff864a8025f05 (0x5b200d) 18: <std::panic::AssertUnwindSafe as core::ops::function::FnOnce<()>>::call_once::h89e08f0726e331d0 (0xdcbacb) 19: std::panicking::try::do_call::h983b221168bcc2f7 (0xdcb334) 20: __rust_maybe_catch_panic (0xf2f0f9) at libpanic_unwind/lib.rs:102 21: rlua::util::callback_error::h63afb414c7b61b5a (0xdc1531) 22: rlua::lua::Lua::create_callback::call_callback::h74378ef5992b49a5 (0xdc725c) 23: luaD_precall (0xdd7bc3) 24: luaV_execute (0xdf17d8) 25: luaD_callnoyield (0xdd8366) 26: luaD_rawrunprotected (0xdd6cd1) 27: luaD_pcall (0xdd882e) 28: lua_pcallk (0xdcfdda) 29: rlua::util::safe_xpcall::h4217653c07f39628 (0xdc1ccf) 30: luaD_precall (0xdd7bc3) 31: luaV_execute (0xdf1574) 32: resume (0xdd81c5) 33: luaD_rawrunprotected (0xdd6cd1) 34: lua_resume (0xdd84a2) 35: luaB_coresume (0xdd40cd) 36: luaD_precall (0xdd7bc3) 37: luaV_execute (0xdf1574) 38: luaD_callnoyield (0xdd8366) 39: luaD_rawrunprotected (0xdd6cd1) 40: luaD_pcall (0xdd882e) 41: lua_pcallk (0xdcfdda) 42: rlua::function::Function::call::hbaba1d5a96fb01cf (0x687aca) 43: rlua::lua::Lua::scope::h7ce907e11c527d42 (0x6960cc) 44: <actix_lua::actor::LuaActor as actix::handler::Handler>::handle::h76ca0ac57c6a8353 (0x691c19) 45: <actix::address::envelope::SyncEnvelopeProxy<A, M> as actix::address::envelope::EnvelopeProxy>::handle::h6ceff87f87b90e3e (0x4c98e3) 46: <actix::mailbox::Mailbox>::poll::hfefb792139fce7ed (0x4cadce) 47: <actix::contextimpl::ContextFut<A, C> as futures::future::Future>::poll::h037704a7c67bbfa5 (0x632533) 48: futures::task_impl::std::set::hc78c4ac62b8470df (0x778661) 49: tokio_current_thread::CurrentRunner::set_spawn::ha2e7969db52cf5f1 (0x76b03a) 50: <tokio_current_thread::scheduler::Scheduler>::tick::hec84cd9eb9909771 (0x799f39) 51: <tokio_current_thread::Entered<'a, P>>::tick::h98279aa5ee241cd9 (0x770169) 52: <tokio_current_thread::Entered<'a, P>>::block_on::h555809293172a4f4 (0x7702ad) 53: <std::thread::local::LocalKey>::with::hc310bbdc2e69cb20 (0x7a7031) 54: <std::thread::local::LocalKey>::with::h2d519306c6199c7b (0x7a394c) 55: <std::thread::local::LocalKey>::with::h697ba33a0a630769 (0x7a4e38) 56: <std::thread::local::LocalKey>::with::h4ab022643a870a98 (0x7a44d9) 57: tokio::runtime::current_thread::runtime::Runtime::block_on::hefb29e4f3faff64f (0x76fbff) 58: std::sys_common::backtrace::rust_begin_short_backtrace::hb597ebe7a5ea293d (0x7953a8) 59: std::panicking::try::do_call::h172a1b011db586a8 (0x76b3a8) 60: rust_maybe_catch_panic (0xf2f0f9) at libpanic_unwind/lib.rs:102 61: <F as alloc::boxed::FnBox>::call_box::hdb317d05dbc9a8a4 (0x76f167) 62: <alloc::boxed::Box<(dyn alloc::boxed::FnBox<A, Output=R> + 'a)> as core::ops::function::FnOnce>::call_once::h80ab30f82670b496 (0xf1da4d) at liballoc/boxed.rs:682 std::sys_common::thread::start_thread::h2eb9063e808b4355 at libstd/sys_common/thread.rs:24 63: std::sys::unix::thread::Thread::new::thread_start::h1c12c88a139098f3 (0xf07cd5) at libstd/sys/unix/thread.rs:90'''

dariusc93 commented 5 years ago

I was just about to run the code to see if it would produce an error. Looking at the trace it does look like it goes back to tera renderer with an unexpected node (looked related to https://github.com/Keats/tera/issues/370). You probably didnt get a direct error because of it panicking than returning a proper error. When I get a minute I will look at the template to get a better understanding of it.

naturallymitchell commented 5 years ago
naturallymitchell commented 5 years ago

progress made via #222 for #128

needs retesting to see if we'll get a better error message now. Luis, please try this after upgrading

LuisReyes98 commented 5 years ago

With the new version the https://github.com/LuisReyes98/found-patterns-theme/tree/crashing_error_in_templeate_searching , still doesn't work but now gives a proper error message:

ERROR:  lighttouch-base/loaders/themes/resolve_template.lua:22: attempt to index a nil value (local 'parent_theme')
stack traceback:
    lighttouch-base/loaders/themes/resolve_template.lua:22: in function 'loaders.themes.resolve_template'
    lighttouch-base/loaders/themes/extends_rewriter.lua:10: in function <lighttouch-base/loaders/themes/extends_rewriter.lua:8>
    [C]: in function 'string.gsub'
    lighttouch-base/loaders/themes/extends_rewriter.lua:8: in local 'fn'
    lighttouch-base/loaders/themes/load_themes.lua:7: in function 'loaders.themes.load_themes'
    lighttouch-base/base.lua:28: in main chunk
    [C]: in function '_require'
    [string "?"]:8: in function 'require'
    lighttouch-base/init.lua:10: in local 'init_f'
    [string "?"]:15: in function <[string "?"]:11>
    [C]: in function 'xpcall'
    [string "?"]:11: in main chunk

where the error is that the value of the parent theme is nil

naturallymitchell commented 5 years ago

this issue now can be resolved by changing lighttouch theme loader

naturallymitchell commented 5 years ago
naturallymitchell commented 5 years ago

Our updated plan:

  • Make the Include FrameType a condensed clone of the including template's frame stack
  • Make a fuction that creates an Include FrameType given an existing FrameStack
  • Start the included template's processor with an Origin Frame and an Include frame on top it

This makes include more powerful than the current one, more secure and less bug-prone than sharing the frame stack, but with a linear performance cost, so developer's will need to use it carefully.

this potentially has value https://github.com/Keats/tera/pull/321