Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault in Handlebars #179

Closed
matthiasbeyer opened this issue Aug 28, 2017 · 14 comments
Closed

Segfault in Handlebars #179

matthiasbeyer opened this issue Aug 28, 2017 · 14 comments

Comments

@matthiasbeyer
Copy link
Contributor

I just experienced a segfault which seems to be originated in the handlebars code.

As there are ~6000 stack levels, it seems that I ended up crashing into the heap by recursing too deep. The recursion seems to happen in handlebars, as only a few (as in below 10) stack levels are from my code.

The corrosponding code is here, here is the causing call.

The templates can be found here, the registration of the templates and the helpers is here. If you have any questions regarding the code, feel free to ask me, I know the codebase is pretty big and maybe confusing for some people.


To reproduce:

  • Clone the repository, checkout the branch from the PR
  • cargo build --manifest-path bin/core/imag-store/Cargo.toml # takes some time
  • mkdir /tmp/store/
  • ./target/debug/imag-store --rtp /tmp/ --config imagrc.toml create -p test entry -c foo
  • enjoy.

The last few lines of the stacktrace follow


#6274 0x00005555556808c2 in core::result::Result<&handlebars::template::Template, handlebars::error::RenderError>::and_then<&handlebars::template::Template,handlebars::error::RenderError,(),closure> (self=Ok = {...}, op=closure = {...})
    at /build/rustc-1.17.0-src/src/libcore/result.rs:601
#6275 0x00005555555f8b18 in handlebars::registry::Registry::renderw<collections::btree::map::BTreeMap<&str, collections::string::String>> (self=0x7ffff6ab9038, name="DEBUG", data=0x7fffffff5578, writer=&mut Write)
    at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:247
#6276 0x00005555555f8654 in handlebars::registry::Registry::render<collections::btree::map::BTreeMap<&str, collections::string::String>> (self=0x7ffff6ab9038, name="DEBUG", data=0x7fffffff5578)
    at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:236
#6277 0x00005555556f75c4 in libimagrt::logger::{{impl}}::log (self=0x7ffff6ab9000, record=0x7fffffff5a50) at /home/m/archive/development/rust/imag/lib/core/libimagrt/src/logger.rs:149
#6278 0x0000555555e16a17 in log::__log (level=log::LogLevel::Debug, target="handlebars::render", loc=0x5555562f06a8 <<handlebars::template::TemplateElement as handlebars::render::Renderable>::render::_LOC>, args=Arguments = {...})
    at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.3.8/src/lib.rs:903
#6279 0x0000555555ae6784 in handlebars::render::{{impl}}::render (self=0x7ffff6a35400, registry=0x7ffff6ab9038, rc=0x7fffffff7038) at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/render.rs:641
#6280 0x0000555555ae5e41 in handlebars::render::{{impl}}::render (self=0x7ffff6a37718, registry=0x7ffff6ab9038, rc=0x7fffffff7038) at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/render.rs:590
#6281 0x00005555555f8f6e in handlebars::registry::{{impl}}::renderw::{{closure}}<collections::btree::map::BTreeMap<&str, collections::string::String>> (t=0x7ffff6a37718) at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:254
#6282 0x00005555556808c2 in core::result::Result<&handlebars::template::Template, handlebars::error::RenderError>::and_then<&handlebars::template::Template,handlebars::error::RenderError,(),closure> (self=Ok = {...}, op=closure = {...})
    at /build/rustc-1.17.0-src/src/libcore/result.rs:601
#6283 0x00005555555f8b18 in handlebars::registry::Registry::renderw<collections::btree::map::BTreeMap<&str, collections::string::String>> (self=0x7ffff6ab9038, name="DEBUG", data=0x7fffffff79d8, writer=&mut Write)
    at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:247
#6284 0x00005555555f8654 in handlebars::registry::Registry::render<collections::btree::map::BTreeMap<&str, collections::string::String>> (self=0x7ffff6ab9038, name="DEBUG", data=0x7fffffff79d8)
    at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:236
#6285 0x00005555556f75c4 in libimagrt::logger::{{impl}}::log (self=0x7ffff6ab9000, record=0x7fffffff7eb0) at /home/m/archive/development/rust/imag/lib/core/libimagrt/src/logger.rs:149
#6286 0x0000555555e16a17 in log::__log (level=log::LogLevel::Debug, target="handlebars::render", loc=0x5555562f06a8 <<handlebars::template::TemplateElement as handlebars::render::Renderable>::render::_LOC>, args=Arguments = {...})
    at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.3.8/src/lib.rs:903
#6287 0x0000555555ae6784 in handlebars::render::{{impl}}::render (self=0x7ffff6a35400, registry=0x7ffff6ab9038, rc=0x7fffffff9498) at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/render.rs:641
#6288 0x0000555555ae5e41 in handlebars::render::{{impl}}::render (self=0x7ffff6a37718, registry=0x7ffff6ab9038, rc=0x7fffffff9498) at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/render.rs:590
#6289 0x00005555555f8f6e in handlebars::registry::{{impl}}::renderw::{{closure}}<collections::btree::map::BTreeMap<&str, collections::string::String>> (t=0x7ffff6a37718) at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:254
#6290 0x00005555556808c2 in core::result::Result<&handlebars::template::Template, handlebars::error::RenderError>::and_then<&handlebars::template::Template,handlebars::error::RenderError,(),closure> (self=Ok = {...}, op=closure = {...})
    at /build/rustc-1.17.0-src/src/libcore/result.rs:601
#6291 0x00005555555f8b18 in handlebars::registry::Registry::renderw<collections::btree::map::BTreeMap<&str, collections::string::String>> (self=0x7ffff6ab9038, name="DEBUG", data=0x7fffffff9e38, writer=&mut Write)
    at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:247
---Type <return> to continue, or q <return> to quit---
#6292 0x00005555555f8654 in handlebars::registry::Registry::render<collections::btree::map::BTreeMap<&str, collections::string::String>> (self=0x7ffff6ab9038, name="DEBUG", data=0x7fffffff9e38)
    at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:236
#6293 0x00005555556f75c4 in libimagrt::logger::{{impl}}::log (self=0x7ffff6ab9000, record=0x7fffffffa310) at /home/m/archive/development/rust/imag/lib/core/libimagrt/src/logger.rs:149

#6294 0x0000555555e16a17 in log::__log (level=log::LogLevel::Debug, target="libimagrt::runtime", loc=0x5555562e92f0 <libimagrt::runtime::Runtime::_new::_LOC>, args=Arguments = {...}) at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.3.8/src/lib.rs:903
#6295 0x00005555555d4d34 in libimagrt::runtime::Runtime::_new<clap::app::App> (cli_app=App = {...}, matches=ArgMatches = {...}, Python Exception <type 'exceptions.ValueError'> invalid literal for int() with base 0: '0x1 <error: Cannot access memory at address 0x1>': 
config=...) at <log macros>:7
#6296 0x00005555555d4319 in libimagrt::runtime::Runtime::new<clap::app::App> (cli_app=App = {...}) at /home/m/archive/development/rust/imag/lib/core/libimagrt/src/runtime.rs:97
#6297 0x00005555555d360d in libimagrt::setup::generate_runtime_setup<fn(clap::app::App) -> clap::app::App> (name="imag-store", version="0.4.0", about="Direct interface to the store. Use with great care!", builder=0x0)
    at /home/m/archive/development/rust/imag/lib/core/libimagrt/src/setup.rs:39
#6298 0x00005555555e642c in imag_store::main () at /home/m/archive/development/rust/imag/bin/core/imag-store/src/main.rs:71
@sunng87
Copy link
Owner

sunng87 commented Aug 28, 2017

Hi @matthiasbeyer , from what I can see in the dump, it might be your data structure has recursive reference so when serde_json tries to convert it to Value, it causes stack overflow.

#0 0x00007fcb464888c0 in raise () from /usr/lib/libc.so.6
#1 0x00007fcb46489f72 in abort () from /usr/lib/libc.so.6
#2 0x0000002e24b9b98b in std::sys::imp::abort_internal () at /checkout/src/libstd/sys/unix/mod.rs:155
#3 std::sys_common::util::abort () at /checkout/src/libstd/sys_common/util.rs:43
#4 0x0000002e24b9e70b in std::sys::imp::stack_overflow::imp::signal_handler ()
at /checkout/src/libstd/sys/unix/stack_overflow.rs:112
#5
#6 alloc::btree::node::Root<alloc::string::String, serde_json::value::Value>::new_leafalloc::string::String,serde_json::value::Value () at /checkout/src/liballoc/btree/node.rs:176
#7 0x0000002e2480994f in alloc::btree::map::BTreeMap<alloc::string::String, serde_json::value::Value>::newalloc::string::String,serde_json::value::Value () at /checkout/src/liballoc/btree/map.rs:526
#8 0x0000002e2481d2af in serde_json::map::Map<alloc::string::String, serde_json::value::Value>::new ()
at /home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.2/src/map.rs:45
#9 0x0000002e2481d71d in serde_json::value::ser::{{impl}}::serialize_map (self=..., _len=...)
at /home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.2/src/value/ser.rs:220
#10 0x0000002e2436cfc3 in serde::ser::Serializer::collect_map<serde_json::value::ser::Serializer,&&str,&alloc::string::String,&alloc::btree::map::BTreeMap<&str, alloc::string::String>> (self=...,
iter=0x7ffc37cc19e8)
at /home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.11/src/ser/mod.rs:1289
#11 0x0000002e2436eec4 in serde::ser::impls::{{impl}}::serialize<&str,alloc::string::String,serde_json::value::ser::Serializer> (self=0x7ffc37cc19e8, serializer=...)
at /home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.11/src/ser/impls.rs:308
#12 0x0000002e2436e9e7 in serde::ser::impls::{{impl}}::serialize<alloc::btree::map::BTreeMap<&str, alloc::string::String>,serde_json::value::ser::Serializer> (self=0x7ffc37cc0d48, serializer=...)
at /home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.11/src/ser/impls.rs:330
#13 0x0000002e2429cd54 in serde_json::value::to_value<&alloc::btree::map::BTreeMap<&str, alloc::string::String>> (value=0x7ffc37cc19e8)
at /home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.2/src/value/mod.rs:985
#14 0x0000002e242924c4 in handlebars::context::Context::wraps<alloc::btree::map::BTreeMap<&str, alloc::string::String>> (e=0x7ffc37cc19e8)
at /home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/context.rs:127
#15 0x0000002e2429326c in handlebars::registry::{{impl}}::renderw::{{closure}}<alloc::btree::map::BTreeMap<&str, alloc::string::String>> (t=0x7fcb45c352f8)
at /home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:250
#16 0x0000002e24318955 in core::result::Result<&handlebars::template::Template, handlebars::error::RenderError>::and_then<&handlebars::template::Template,handlebars::error::RenderError,(),closure> (self=...,
op=...) at /checkout/src/libcore/result.rs:602
#17 0x0000002e24293155 in handlebars::registry::Registry::renderw<alloc::btree::map::BTreeMap<&str, alloc::string::String>> (self=0x7fcb45cb4038, name=..., data=0x7ffc37cc19e8, writer=...)
at /home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:247
#18 0x0000002e24292ca3 in handlebars::registry::Registry::render<alloc::btree::map::BTreeMap<&str, alloc::string::String>> (self=0x7fcb45cb4038, name=..., data=0x7ffc37cc19e8)
at /home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:236
#19 0x0000002e243ab720 in libimagrt::logger::{{impl}}::log (self=0x7fcb45cb4000, record=0x7ffc37cc1ec0)
at lib/core/libimagrt/src/logger.rs:149
#20 0x0000002e24b82a0f in log::__log (level=log::LogLevel::Debug, target=...,
loc=0x2e250bcc30 <<handlebars::template::TemplateElement as handlebars::render::Renderable>::render::_LOC>, args=...) at /home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.3.8/src/lib.rs:903
#21 0x0000002e247e7e07 in handlebars::render::{{impl}}::render (self=0x7fcb45c33400,
registry=0x7fcb45cb4038, rc=0x7ffc37cc3458)
at /home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/render.rs:641
#22 0x0000002e247e753c in handlebars::render::{{impl}}::render (self=0x7fcb45c352f8,
registry=0x7fcb45cb4038, rc=0x7ffc37cc3458)
at /home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/render.rs:590
#23 0x0000002e24293569 in handlebars::registry::{{impl}}::renderw::{{closure}}<alloc::btree::map::BTreeMap<&str, alloc::string::String>> (t=0x7fcb45c352f8)

Let me look into the code for further information.

@sunng87
Copy link
Owner

sunng87 commented Aug 28, 2017

By the way, I was using coredumpctl gdb pid, then type bt for backtrace in gdb

@matthiasbeyer
Copy link
Contributor Author

Can you point out where my code seems to have a recursive reference?

@sunng87
Copy link
Owner

sunng87 commented Aug 29, 2017

@matthiasbeyer Just added some debug print to your log function I saw it's all about handlebars:

entering log
{"file": "/home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/render.rs", "level": "DEBUG", "line": "641", "message": "rendering RawString("[imag]["), partials: {}, path: ".", local_variables: {}, current_template: Some("DEBUG"), root_template: Some("DEBUG"), disable_escape: false, local_path_root: []", "module_path": "handlebars::render", "target": "handlebars::render"}
entering log
{"file": "/home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/render.rs", "level": "DEBUG", "line": "641", "message": "rendering RawString("[imag]["), partials: {}, path: ".", local_variables: {}, current_template: Some("DEBUG"), root_template: Some("DEBUG"), disable_escape: false, local_path_root: []", "module_path": "handlebars::render", "target": "handlebars::render"}
entering log
{"file": "/home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/render.rs", "level": "DEBUG", "line": "641", "message": "rendering RawString("[imag]["), partials: {}, path: ".", local_variables: {}, current_template: Some("DEBUG"), root_template: Some("DEBUG"), disable_escape: false, local_path_root: []", "module_path": "handlebars::render", "target": "handlebars::render"}
entering log
{"file": "/home/nsun/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/render.rs", "level": "DEBUG", "line": "641", "message": "rendering RawString("[imag]["), partials: {}, path: ".", local_variables: {}, current_template: Some("DEBUG"), root_template: Some("DEBUG"), disable_escape: false, local_path_root: []", "module_path": "handlebars::render", "target": "handlebars::render"}

When I comment out handlebars rendering code like:

    fn log(&self, record: &LogRecord) {
        println!("entering log");
        let mut data = BTreeMap::new();

        {
            data.insert("level", format!("{}", record.level()));
            data.insert("module_path", String::from(record.location().module_path()));
            data.insert("file", String::from(record.location().file()));
            data.insert("line", format!("{}", record.location().line()));
            data.insert("target", String::from(record.target()));
            data.insert("message", format!("{}", record.args()));
        }

        println!("------");
        println!("{:?}", data);
        // let logtext = self
        //     .handlebars
        //     .render(&format!("{}", record.level()), &data)
        //     .unwrap_or_else(|e| format!("Failed rendering logging data: {:?}\n", e));

        // self.module_settings
        //     .get(record.target())
        //     .map(|module_setting| {
        //         let set = module_setting.enabled &&
        //             module_setting.level.unwrap_or(self.global_loglevel) >= record.level();

        //         if set {
        //             let _ = write!(stderr(), "{}", logtext);
        //         }
        //     })
        //     .unwrap_or_else(|| {
        //         if self.global_loglevel >= record.level() {
        //             // Yes, we log
        //             let _ = write!(stderr(), "{}", logtext);
        //         }
        //     });
    }

It seems correct:

entering log
{"file": "lib/core/libimagrt/src/runtime.rs", "level": "DEBUG", "line": "127", "message": "Not generating shell completion script", "module_path": "libimagrt::runtime", "target": "libimagrt::runtime"}
entering log
{"file": "lib/core/libimagrt/src/runtime.rs", "level": "DEBUG", "line": "139", "message": "RTP path = "/tmp/"", "module_path": "libimagrt::runtime", "target": "libimagrt::runtime"}
entering log
{"file": "lib/core/libimagrt/src/runtime.rs", "level": "DEBUG", "line": "140", "message": "Store path = "/tmp/store"", "module_path": "libimagrt::runtime", "target": "libimagrt::runtime"}
entering log
{"file": "lib/core/libimagstore/src/store.rs", "level": "DEBUG", "line": "266", "message": "Validating Store configuration", "module_path": "libimagstore::store", "target": "libimagstore::store"}
entering log
{"file": "lib/core/libimagstore/src/store.rs", "level": "DEBUG", "line": "269", "message": "Building new Store object", "module_path": "libimagstore::store", "target": "libimagstore::store"}
entering log
{"file": "lib/core/libimagstore/src/store.rs", "level": "DEBUG", "line": "295", "message": "Store building succeeded", "module_path": "libimagstore::store", "target": "libimagstore::store"}
entering log
{"file": "lib/core/libimagstore/src/store.rs", "level": "DEBUG", "line": "296", "message": "------------------------", "module_path": "libimagstore::store", "target": "libimagstore::store"}
entering log
{"file": "lib/core/libimagstore/src/store.rs", "level": "DEBUG", "line": "297", "message": " --- Store ---\n\n - location : "/tmp/store"\n - configuration : Some(Table({"implicit-create": Boolean(false)}))\n\nEntries:\nRwLock { data: {} }\n", "module_path": "libimagstore::store", "target": "libimagstore::store"}
entering log
{"file": "lib/core/libimagstore/src/store.rs", "level": "DEBUG", "line": "298", "message": "------------------------", "module_path": "libimagstore::store", "target": "libimagstore::store"}
entering log
{"file": "bin/core/imag-store/src/main.rs", "level": "DEBUG", "line": "79", "message": "Call: create", "module_path": "imag_store", "target": "imag_store"}
entering log
{"file": "bin/core/imag-store/src/create.rs", "level": "DEBUG", "line": "49", "message": "Found 'create' subcommand...", "module_path": "imag_store::create", "target": "imag_store::create"}
entering log
{"file": "lib/core/libimagstore/src/storeid.rs", "level": "DEBUG", "line": "70", "message": "Trying to get a new baseless id from: "test"", "module_path": "libimagstore::storeid", "target": "libimagstore::storeid"}
entering log
{"file": "bin/core/imag-store/src/create.rs", "level": "DEBUG", "line": "64", "message": "path = StoreId { base: Some("/tmp/store"), id: "test" }", "module_path": "imag_store::create", "target": "imag_store::create"}
entering log
{"file": "bin/core/imag-store/src/create.rs", "level": "DEBUG", "line": "67", "message": "Creating entry from CLI specification", "module_path": "imag_store::create", "target": "imag_store::create"}
entering log
{"file": "bin/core/imag-store/src/create.rs", "level": "DEBUG", "line": "93", "message": "Found entry subcommand, parsing content", "module_path": "imag_store::create", "target": "imag_store::create"}
entering log
{"file": "bin/core/imag-store/src/create.rs", "level": "DEBUG", "line": "101", "message": "Got content with len = 3", "module_path": "imag_store::create", "target": "imag_store::create"}
entering log
{"file": "bin/core/imag-store/src/util.rs", "level": "DEBUG", "line": "30", "message": "Building header from cli spec", "module_path": "imag_store::util", "target": "imag_store::util"}
entering log
{"file": "bin/core/imag-store/src/util.rs", "level": "DEBUG", "line": "51", "message": "Header = Table({"imag": Table({"links": Array([]), "version": String("0.4.0")})})", "module_path": "imag_store::util", "target": "imag_store::util"}
entering log
{"file": "bin/core/imag-store/src/create.rs", "level": "DEBUG", "line": "144", "message": "Creating entry with content at StoreId { base: Some("/tmp/store"), id: "test" }", "module_path": "imag_store::create", "target": "imag_store::create"}
entering log
{"file": "lib/core/libimagstore/src/store.rs", "level": "DEBUG", "line": "405", "message": "Creating id: 'test'", "module_path": "libimagstore::store", "target": "libimagstore::store"}
entering log
{"file": "lib/core/libimagstore/src/store.rs", "level": "DEBUG", "line": "418", "message": "Creating: 'test'", "module_path": "libimagstore::store", "target": "libimagstore::store"}
entering log
{"file": "lib/core/libimagstore/src/store.rs", "level": "DEBUG", "line": "425", "message": "Constructing FileLockEntry: 'test'", "module_path": "libimagstore::store", "target": "libimagstore::store"}
entering log
{"file": "bin/core/imag-store/src/create.rs", "level": "DEBUG", "line": "152", "message": "New content set", "module_path": "imag_store::create", "target": "imag_store::create"}
entering log
{"file": "bin/core/imag-store/src/create.rs", "level": "DEBUG", "line": "157", "message": "New header set", "module_path": "imag_store::create", "target": "imag_store::create"}
entering log
{"file": "lib/core/libimagstore/src/store.rs", "level": "DEBUG", "line": "569", "message": "Verifying Entry", "module_path": "libimagstore::store", "target": "libimagstore::store"}
entering log
{"file": "lib/core/libimagstore/src/toml_ext.rs", "level": "DEBUG", "line": "429", "message": "Verifying that table has only tables", "module_path": "libimagstore::toml_ext", "target": "libimagstore::toml_ext"}
entering log
{"file": "lib/core/libimagstore/src/store.rs", "level": "DEBUG", "line": "572", "message": "Writing Entry", "module_path": "libimagstore::store", "target": "libimagstore::store"}
entering log
{"file": "lib/core/libimagstore/src/file_abstraction/fs.rs", "level": "DEBUG", "line": "160", "message": "Implicitely creating directory: "/tmp/store"", "module_path": "libimagstore::file_abstraction::fs", "target": "libimagstore::file_abstraction::fs"}
entering log
{"file": "lib/core/libimagstore/src/store.rs", "level": "DEBUG", "line": "828", "message": "Dropping store", "module_path": "libimagstore::store", "target": "libimagstore::store"}

So it has something to do with line 641 where I have a debug log debug!("rendering {:?}, {:?}", self, rc);. After this line removed, it works correctly.

I can remove it from handlebars. But I guess this might be an issue you may be interested in.

@sunng87
Copy link
Owner

sunng87 commented Aug 29, 2017

Let me know if you can fix it from your code. Otherwise I will publish an update with the debug log removed.

@matthiasbeyer
Copy link
Contributor Author

Thanks for your investigation.

I do not see, though, where the error is. Can you explain, please?

@sunng87
Copy link
Owner

sunng87 commented Aug 29, 2017

It seems your logger is logging debug! logs from handlebars. Just add some println! to your data and you can see it.

@matthiasbeyer
Copy link
Contributor Author

Ah, you mean that handlebars uses logging and because of that my logger recurses. Now I understand the problem.

Well, then it'd be good if handlebars could add a compiletime feature to disable logging, I guess. Feel free to borrow my solution on this problem from the toml-query crate where I create macros if logging is disabled.

@matthiasbeyer
Copy link
Contributor Author

Maybe we could even author a new crate for exactly this use-case... if there isn't one already!

@sunng87
Copy link
Owner

sunng87 commented Aug 30, 2017

@matthiasbeyer by designing the logging API a macro, I believe the author is to eliminate runtime overhead for logging at all if you didn't enable it. So it seems redundant to add another feature toggle for it.

I think you should fix it from your codebase or use your own logging macros as you said.

@matthiasbeyer
Copy link
Contributor Author

@matthiasbeyer by designing the logging API a macro, I believe the author is to eliminate runtime overhead for logging at all if you didn't enable it. So it seems redundant to add another feature toggle for it.

Sorry, but I don't understand this statement at all.

I think you should fix it from your codebase or use your own logging macros as you said.

Then I would need to fork handlebars and maintain a patch on top of my own fork, using my own fork in my imag codebase. Having it upstream in handlebars would eliminate this "maintain overhead" and others can profit from it, too, by disable logging in handlebars at compiletime.

@sunng87
Copy link
Owner

sunng87 commented Aug 31, 2017

Ok I'll remove the debug log and release a new version tonight

@matthiasbeyer
Copy link
Contributor Author

I added a workaround to my codebase here but that's not a thing one should need to do when using the handlebars crate in a logger.

Thanks for your efforts! 👍

@sunng87
Copy link
Owner

sunng87 commented Aug 31, 2017

Fix released in 0.29.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants