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

Segmentation fault with multiple block partials #400

Closed
rplopes opened this issue Dec 12, 2020 · 4 comments · Fixed by #401
Closed

Segmentation fault with multiple block partials #400

rplopes opened this issue Dec 12, 2020 · 4 comments · Fixed by #401
Assignees
Labels

Comments

@rplopes
Copy link

rplopes commented Dec 12, 2020

I'm getting segmentation fault when working with more than one partial using the block notation.

I've managed to isolate the issue into the following code:

use handlebars::Handlebars;
use std::collections::HashMap;

fn main() {
    let mut handlebars = Handlebars::new();
    let template1 = "<outer>{{> @partial-block }}</outer>";
    let template2 = "{{#> t1 }}<inner>{{> @partial-block }}</inner>{{/ t1 }}";
    let template3 = "{{#> t2 }}Hello{{/ t2 }}";

    handlebars
       .register_template_string("t1", &template1)
       .unwrap();
    handlebars
       .register_template_string("t2", &template2)
       .unwrap();

    let mut data = HashMap::new();
    data.insert("hello".to_string(), "world");

    let page = handlebars.render_template(&template3, &data).unwrap();
    println!("{}", page);
}

Running this code, what I expected:

<outer><inner>Hello</inner></outer>

However, this is what I'm getting instead:

[2]    1953 segmentation fault  cargo run
@sunng87 sunng87 self-assigned this Dec 13, 2020
@sunng87 sunng87 added the bug label Dec 13, 2020
@sunng87
Copy link
Owner

sunng87 commented Dec 13, 2020

It seems stack overflow happened for @partial-block. Thank you for reporting and I will look into this.

@sunng87
Copy link
Owner

sunng87 commented Dec 24, 2020

@rplopes could you please try fix in #401 if it works for your case?

@rplopes
Copy link
Author

rplopes commented Dec 24, 2020

I can confirm it works great indeed, awesome work 👍

@sunng87
Copy link
Owner

sunng87 commented Dec 25, 2020

@rplopes Thank you again for verifying and your test case has been super helpful.

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

Successfully merging a pull request may close this issue.

2 participants