serde-rs / serde

Serialization framework for Rust
https://serde.rs/
Apache License 2.0
9.2k stars 778 forks source link

Stack overflow in serde_codegen #494

Closed dtolnay closed 8 years ago

dtolnay commented 8 years ago

@jaredwy reports a failure building https://github.com/jaredwy/friendlyrust/commit/3eeb0350b34384decff29306080cc9e3b1d8ad67 on OS X 10.10.5 using Rust 1.10.0 and serde_codegen 0.8.0, 0.8.1 and master.

--- stderr
thread '<main>' has overflowed its stack
fatal runtime error: stack overflow

He reports that the same commit builds fine on Windows. It builds fine for me on Linux as well as OS X 10.11.6 using Rust 1.10.0 so there is not much to go on. Possibly related to #229.

oli-obk commented 8 years ago

serde_codegen 0.8.1 allows setting the RUST_MIN_STACK environment variable (see #486) to increase the stack used, until we have a better solution.

@alexcrichton what is the stack size you are using now? I'd like to hardcode it if the RUST_MIN_STACK env var is missing

jaredwy commented 8 years ago

Thanks! Will play around. Is it possible to get this documented for 8.1?

alexcrichton commented 8 years ago

@oli-obk I set the stack size to 16 MB

jaredwy commented 8 years ago

export RUST_MIN_STACK=16777216 && cargo clean && cargo build same symptoms. Also tried 32mb.

oli-obk commented 8 years ago

I set the stack size to 16 MB

thanks

same symptoms. Also tried 32mb.

ok, that's pretty weird. Since it builds on other systems, it can't be infinite recursion. Can you try building it in release mode? Maybe optimizations will help on your system. Also, run with --verbose, figure out the exact command that is failing, maybe it's in the rustc compiler? Once you figure out which call it is, run it through a debugger and post the stacktrace.

jaredwy commented 8 years ago

@oli-obk will debug when i get a spare moment. The output from --verbose suggests it isn't rustc

Unless serde_codegen::expand(path, &dst).unwrap(); is invoking the compiler?

     Running `rustc build.rs --crate-name build_script_build --crate-type bin -g --out-dir /Users/wyles/src/friendlyrust/target/debug/build/friendlyrust-79efe07d0736efe2 --emit=dep-info,link -L dependency=/Users/wyles/src/friendlyrust/target/debug -L dependency=/Users/wyles/src/friendlyrust/target/debug/deps --extern glob=/Users/wyles/src/friendlyrust/target/debug/deps/libglob-028bcc81f721b7f5.rlib --extern serde_codegen=/Users/wyles/src/friendlyrust/target/debug/deps/libserde_codegen-b5568745a0b7071c.rlib`
     Running `/Users/wyles/src/friendlyrust/target/debug/build/friendlyrust-79efe07d0736efe2/build-script-build`
error: failed to run custom build command for `friendlyrust v0.1.0 (file:///Users/wyles/src/friendlyrust)`
Process didn't exit successfully: `/Users/wyles/src/friendlyrust/target/debug/build/friendlyrust-79efe07d0736efe2/build-script-build` (signal: 6, SIGABRT: process abort signal)
--- stdout
Some("pullrequest.rs")

^^ thats the file name that it is failing on.

oli-obk commented 8 years ago

ok, so with gdb you should be able to execute the target/debug/build/friendlyrust-79efe07d0736efe2/build-script-build file directly.

jaredwy commented 8 years ago

Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x00007fff5fb80288 0x00000001004fba83 in _ZN13syntex_syntax5print6pprust8{{impl}}27print_expr_outer_attr_styleE (self=0x7fff5fbe9b68, expr=0x101646a20, is_inline=true) at pprust.rs:1973 1973 try!(self.maybe_print_comment(expr.span.lo));

This is where it fails. Grabbing the stack at the moment.

jaredwy commented 8 years ago

long post to follow(switched to lldb because its what i know :))

 * frame #0: 0x00000001004fba83 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101646a20, is_inline=true) + 1043 at pprust.rs:1973
    frame #1: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101646a20) + 41 at pprust.rs:1967
    frame #2: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fb84260, lhs=0x0000000101646a20, rhs=0x0000000101675f80) + 488 at pprust.rs:1940
    frame #3: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101675080, is_inline=true) + 4844 at pprust.rs:2011
    frame #4: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101675080) + 41 at pprust.rs:1967
    frame #5: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fb88360, lhs=0x0000000101675080, rhs=0x0000000101674e00) + 488 at pprust.rs:1940
    frame #6: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x00000001016474c0, is_inline=true) + 4844 at pprust.rs:2011
    frame #7: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x00000001016474c0) + 41 at pprust.rs:1967
    frame #8: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fb8c460, lhs=0x00000001016474c0, rhs=0x0000000101675940) + 488 at pprust.rs:1940
    frame #9: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101675620, is_inline=true) + 4844 at pprust.rs:2011
    frame #10: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101675620) + 41 at pprust.rs:1967
    frame #11: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fb90560, lhs=0x0000000101675620, rhs=0x0000000101675580) + 488 at pprust.rs:1940
    frame #12: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101675440, is_inline=true) + 4844 at pprust.rs:2011
    frame #13: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101675440) + 41 at pprust.rs:1967
    frame #14: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fb94660, lhs=0x0000000101675440, rhs=0x00000001016762a0) + 488 at pprust.rs:1940
    frame #15: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101701f20, is_inline=true) + 4844 at pprust.rs:2011
    frame #16: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101701f20) + 41 at pprust.rs:1967
    frame #17: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fb98760, lhs=0x0000000101701f20, rhs=0x0000000101701fc0) + 488 at pprust.rs:1940
    frame #18: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101702100, is_inline=true) + 4844 at pprust.rs:2011
    frame #19: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101702100) + 41 at pprust.rs:1967
    frame #20: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fb9c860, lhs=0x0000000101702100, rhs=0x0000000101645bc0) + 488 at pprust.rs:1940
    frame #21: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101645d00, is_inline=true) + 4844 at pprust.rs:2011
    frame #22: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101645d00) + 41 at pprust.rs:1967
    frame #23: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fba0960, lhs=0x0000000101645d00, rhs=0x0000000101645800) + 488 at pprust.rs:1940
    frame #24: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x00000001016456c0, is_inline=true) + 4844 at pprust.rs:2011
    frame #25: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x00000001016456c0) + 41 at pprust.rs:1967
    frame #26: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fba4a60, lhs=0x00000001016456c0, rhs=0x0000000101643c80) + 488 at pprust.rs:1940
    frame #27: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101644540, is_inline=true) + 4844 at pprust.rs:2011
    frame #28: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101644540) + 41 at pprust.rs:1967
    frame #29: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fba8b60, lhs=0x0000000101644540, rhs=0x0000000101644c20) + 488 at pprust.rs:1940
    frame #30: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101644b80, is_inline=true) + 4844 at pprust.rs:2011
    frame #31: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101644b80) + 41 at pprust.rs:1967
    frame #32: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fbacc60, lhs=0x0000000101644b80, rhs=0x00000001016449a0) + 488 at pprust.rs:1940
    frame #33: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101644680, is_inline=true) + 4844 at pprust.rs:2011
    frame #34: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101644680) + 41 at pprust.rs:1967
    frame #35: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fbb0d60, lhs=0x0000000101644680, rhs=0x0000000101674f40) + 488 at pprust.rs:1940
    frame #36: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101712f00, is_inline=true) + 4844 at pprust.rs:2011
    frame #37: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101712f00) + 41 at pprust.rs:1967
    frame #38: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fbb4e60, lhs=0x0000000101712f00, rhs=0x0000000101702920) + 488 at pprust.rs:1940
    frame #39: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101707380, is_inline=true) + 4844 at pprust.rs:2011
    frame #40: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101707380) + 41 at pprust.rs:1967
    frame #41: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fbb8f60, lhs=0x0000000101707380, rhs=0x00000001016467a0) + 488 at pprust.rs:1940
    frame #42: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101702240, is_inline=true) + 4844 at pprust.rs:2011
    frame #43: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101702240) + 41 at pprust.rs:1967
    frame #44: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fbbd060, lhs=0x0000000101702240, rhs=0x00000001017022e0) + 488 at pprust.rs:1940
    frame #45: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101643fa0, is_inline=true) + 4844 at pprust.rs:2011
    frame #46: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101643fa0) + 41 at pprust.rs:1967
    frame #47: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fbc1160, lhs=0x0000000101643fa0, rhs=0x0000000101707060) + 488 at pprust.rs:1940
    frame #48: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101645b20, is_inline=true) + 4844 at pprust.rs:2011
    frame #49: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101645b20) + 41 at pprust.rs:1967
    frame #50: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fbc5260, lhs=0x0000000101645b20, rhs=0x00000001016460c0) + 488 at pprust.rs:1940
    frame #51: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101706e80, is_inline=true) + 4844 at pprust.rs:2011
    frame #52: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101706e80) + 41 at pprust.rs:1967
    frame #53: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fbc9360, lhs=0x0000000101706e80, rhs=0x0000000101706de0) + 488 at pprust.rs:1940
    frame #54: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101706d40, is_inline=true) + 4844 at pprust.rs:2011
    frame #55: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101706d40) + 41 at pprust.rs:1967
    frame #56: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fbcd460, lhs=0x0000000101706d40, rhs=0x0000000101706ac0) + 488 at pprust.rs:1940
    frame #57: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101706ca0, is_inline=true) + 4844 at pprust.rs:2011
    frame #58: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101706ca0) + 41 at pprust.rs:1967
    frame #59: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fbd1560, lhs=0x0000000101706ca0, rhs=0x0000000101706c00) + 488 at pprust.rs:1940
    frame #60: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101706b60, is_inline=true) + 4844 at pprust.rs:2011
    frame #61: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101706b60) + 41 at pprust.rs:1967
    frame #62: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fbd5660, lhs=0x0000000101706b60, rhs=0x0000000101706a20) + 488 at pprust.rs:1940
    frame #63: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101706980, is_inline=true) + 4844 at pprust.rs:2011
    frame #64: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101706980) + 41 at pprust.rs:1967
    frame #65: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fbd9760, lhs=0x0000000101706980, rhs=0x00000001017068e0) + 488 at pprust.rs:1940
    frame #66: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101706840, is_inline=true) + 4844 at pprust.rs:2011
    frame #67: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101706840) + 41 at pprust.rs:1967
    frame #68: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fbdd860, lhs=0x0000000101706840, rhs=0x00000001017067a0) + 488 at pprust.rs:1940
    frame #69: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101706700, is_inline=true) + 4844 at pprust.rs:2011
    frame #70: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101706700) + 41 at pprust.rs:1967
    frame #71: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fbe1960, lhs=0x0000000101706700, rhs=0x0000000101706660) + 488 at pprust.rs:1940
    frame #72: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x00000001017065c0, is_inline=true) + 4844 at pprust.rs:2011
    frame #73: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x00000001017065c0) + 41 at pprust.rs:1967
    frame #74: 0x0000000100513f48 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_binary(self=0x00007fff5fbe9a68, op=Spanned<syntex_syntax::ast::BinOpKind> @ 0x00007fff5fbe5a60, lhs=0x00000001017065c0, rhs=0x0000000101676480) + 488 at pprust.rs:1940
    frame #75: 0x00000001004fc95c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbe9a68, expr=0x0000000101676520, is_inline=true) + 4844 at pprust.rs:2011
    frame #76: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbe9a68, expr=0x0000000101676520) + 41 at pprust.rs:1967
    frame #77: 0x00000001004cf92b build-script-build`syntex_syntax::print::pprust::expr_to_string::{{closure}}(s=0x00007fff5fbe9a68) + 59 at pprust.rs:329
    frame #78: 0x00000001004cf812 build-script-build`syntex_syntax::print::pprust::to_string<closure>(f=closure @ 0x00007fff5fbe9bb8) + 274 at pprust.rs:190
    frame #79: 0x0000000100311b78 build-script-build`syntex_syntax::print::pprust::expr_to_string(e=0x0000000101676520) + 40 at pprust.rs:329
    frame #80: 0x00000001003c79a7 build-script-build`syntex_syntax::print::pprust::token_to_string(tok=0x00000001017283a0) + 6407 at pprust.rs:292
    frame #81: 0x00000001004cfd28 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_tt(self=0x00007fff5fbfd730, tt=0x0000000101728390) + 296 at pprust.rs:1451
    frame #82: 0x00000001004d189c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_tts(self=0x00007fff5fbfd730, tts=&[syntex_syntax::tokenstream::TokenTree] @ 0x00007fff5fbeb1c0) + 1004 at pprust.rs:1489
    frame #83: 0x00000001004d051f build-script-build`syntex_syntax::print::pprust::{{impl}}::print_tt(self=0x00007fff5fbfd730, tt=0x000000010232f4b8) + 2335 at pprust.rs:1462
    frame #84: 0x00000001004d189c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_tts(self=0x00007fff5fbfd730, tts=&[syntex_syntax::tokenstream::TokenTree] @ 0x00007fff5fbebc60) + 1004 at pprust.rs:1489
    frame #85: 0x00000001004ebec1 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_mac(self=0x00007fff5fbfd730, m=0x00000001016a8250, delim=Paren) + 2433 at pprust.rs:1784
    frame #86: 0x00000001004fd55b build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbfd730, expr=0x00000001016a8240, is_inline=true) + 7915 at pprust.rs:2278
    frame #87: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbfd730, expr=0x00000001016a8240) + 41 at pprust.rs:1967
    frame #88: 0x00000001004d2dda build-script-build`syntex_syntax::print::pprust::{{impl}}::print_stmt(self=0x00007fff5fbfd730, st=0x00000001016e5c00) + 4474 at pprust.rs:1616
    frame #89: 0x000000010050a5a8 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_block_maybe_unclosed(self=0x00007fff5fbfd730, blk=0x00000001016963d0, indented=4, attrs=&[syntex_syntax::codemap::Spanned<syntex_syntax::ast::Attribute_>] @ 0x00007fff5fbf0e78, close_box=true) + 2488 at pprust.rs:1698
    frame #90: 0x00000001004f513c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_block_with_attrs(self=0x00007fff5fbfd730, blk=0x00000001016963d0, attrs=&[syntex_syntax::codemap::Spanned<syntex_syntax::ast::Attribute_>] @ 0x00007fff5fbf0ee0) + 92 at pprust.rs:1673
    frame #91: 0x00000001004e1bf8 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_impl_item(self=0x00007fff5fbfd730, ii=0x00000001016e3800) + 4312 at pprust.rs:1581
    frame #92: 0x00000001004ddee2 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_item(self=0x00007fff5fbfd730, item=0x0000000101615b00) + 39634 at pprust.rs:1282
    frame #93: 0x00000001004d1f90 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_stmt(self=0x00007fff5fbfd730, st=0x000000010233ad08) + 816 at pprust.rs:1621
    frame #94: 0x000000010050a5a8 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_block_maybe_unclosed(self=0x00007fff5fbfd730, blk=0x00000001016942d0, indented=4, attrs=&[syntex_syntax::codemap::Spanned<syntex_syntax::ast::Attribute_>] @ 0x00007fff5fbf5cb8, close_box=true) + 2488 at pprust.rs:1698
    frame #95: 0x00000001004f513c build-script-build`syntex_syntax::print::pprust::{{impl}}::print_block_with_attrs(self=0x00007fff5fbfd730, blk=0x00000001016942d0, attrs=&[syntex_syntax::codemap::Spanned<syntex_syntax::ast::Attribute_>] @ 0x00007fff5fbf5d20) + 92 at pprust.rs:1673
    frame #96: 0x00000001005043fa build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr_outer_attr_style(self=0x00007fff5fbfd730, expr=0x00000001016a6620, is_inline=true) + 36234 at pprust.rs:2137
    frame #97: 0x00000001004cf969 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_expr(self=0x00007fff5fbfd730, expr=0x00000001016a6620) + 41 at pprust.rs:1967
    frame #98: 0x00000001004d88e7 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_item(self=0x00007fff5fbfd730, item=0x0000000101622200) + 17623 at pprust.rs:1172
    frame #99: 0x00000001004c1ad0 build-script-build`syntex_syntax::print::pprust::{{impl}}::print_mod(self=0x00007fff5fbfd730, _mod=0x00007fff5fbfdd20, attrs=&[syntex_syntax::codemap::Spanned<syntex_syntax::ast::Attribute_>] @ 0x00007fff5fbfd2b8) + 608 at pprust.rs:934
    frame #100: 0x00000001004b98c9 build-script-build`syntex_syntax::print::pprust::print_crate(cm=0x000000010162d010, span_diagnostic=0x00007fff5fbfec08, krate=0x00007fff5fbfdd20, filename=String @ 0x00007fff5fbfd898, input=&mut Read @ 0x00007fff5fbfd888, out=Box<Write> @ 0x00007fff5fbfd878, ann=&PpAnn @ 0x00007fff5fbfd868, is_expanded=false) + 2569 at pprust.rs:135
    frame #101: 0x0000000100280e03 build-script-build`syntex::{{impl}}::expand_crate(self=Registry @ 0x00007fff5fbfe550, crate_name=(data_ptr = "", length = 0), sess=0x00007fff5fbfec08, src_name=String @ 0x00007fff5fbfe520, krate=Crate @ 0x00007fff5fbfe4a0) + 3699 at lib.rs:238
    frame #102: 0x00000001000199a9 build-script-build`syntex::{{impl}}::expand<&std::path::Path,&std::path::Path>(self=Registry @ 0x00007fff5fbfed08, crate_name=(data_ptr = "", length = 0), src=0x000000010161d100, dst=0x000000010162a030) + 1577 at lib.rs:163
    frame #103: 0x000000010000253d build-script-build`serde_codegen::expand<&std::path::Path,&std::path::PathBuf>(src=0x000000010161d100, dst=0x00007fff5fbff0d8) + 589 at lib.rs:79
    frame #104: 0x0000000100001b86 build-script-build`build_script_build::compile00(path=0x000000010161d100, out_dir=0x000000010161e000) + 1078 at build.rs:13
    frame #105: 0x000000010001f626 build-script-build`build_script_build::main + 854 at build.rs:21
    frame #106: 0x00000001006a08ae build-script-build`std::panicking::try::call::hbbf4746cba890ca7 + 30
    frame #107: 0x00000001006a3c9c build-script-build`__rust_try + 12
    frame #108: 0x00000001006a3c36 build-script-build`__rust_maybe_catch_panic + 38
    frame #109: 0x00000001006a06d2 build-script-build`std::rt::lang_start::hbcefdc316c2fbd45 + 562
    frame #110: 0x0000000100020f9a build-script-build`main + 42
    frame #111: 0x00007fff9c20c5c9 libdyld.dylib`start + 1
    frame #112: 0x00007fff9c20c5c9 libdyld.dylib`start + 1
oli-obk commented 8 years ago

curious, it's not an infinite recursion, but a new sub-expression.

I'm guessing it's caused by the following generated code:

                let mut state =
                    try!(_serializer . serialize_struct (
                         "PullRequestInfo" ,
                         0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1
    + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1
                         ));

It's the only long chained binary expression. But it still makes no sense that upping the stack limit doesn't work for you. Is export RUST_MIN_STACK=16777216 the correct way to do that on OSX? I have no clue... Maybe it's not working :)

We can definitely improve on some of this generated code... But it's going to make the code more complicated to read if we keep adding performance hacks :/

jaredwy commented 8 years ago

export OUT_DIR="/tmp/" && lldb /Users/wyles/src/friendlyrust/target/debug/build/friendlyrust-79efe07d0736efe2/build-script-build runs the following let out_dir = env::var_os("OUT_DIR").unwrap(); and the code in rust that reads it is let amt = env::var("RUST_MIN_STACK").ok().and_then(|s| s.parse().ok()); so pretty sure that is the right way.

jaredwy commented 8 years ago

To satisfy my curiosity dropped a println!("{:?}", env::var_os("RUST_MIN_STACK").unwrap()); into the code.

Then ran export RUST_MIN_STACK=16000001 && cargo build

Outcome is still the same :(

Process didn't exit successfully: `/Users/wyles/src/friendlyrust/target/debug/build/friendlyrust-79efe07d0736efe2/build-script-build` (signal: 6, SIGABRT: process abort signal)
--- stdout
"16000001"
oli-obk commented 8 years ago

oooooh... I'm so stupid. The RUST_MIN_STACK hack was for serde_codegen's build script, but in your case it's your build script that is failing. Please put the entire code of your build script into a thread (don't forget to join the thread) and run everything again.

jaredwy commented 8 years ago

That seems to have fixed the overflow issue. Now i have another issue :) rustc seems to not think pullrequestdata implements serde::de::Deserialize

Will dig around.

jaredwy commented 8 years ago

I think this bug as stands could be closed with some docs :) Perhaps the documentation on https://github.com/serde-rs/serde could be update the build.rs example

it currently reads

#[cfg(feature = "serde_macros")]
mod inner {
    pub fn main() {}
}

fn main() {
    inner::main();
}

that could become

#[cfg(feature = "serde_macros")]
mod inner {
    pub fn main() {}
}

fn main() {
    let child = thread::spawn(move || {
       inner::main();
    }
    child.join()
}

with a note underneath that if you experience a error stackoverflow error set the environment variable RUST_MIN_STACK?

I am happy to make this change if others are happy?

dtolnay commented 8 years ago

Thanks for your help @jaredwy. I updated the setup steps in http://serde.rs/codegen-hybrid.html to use thread::spawn and I added a troubleshooting page mentioning the stack overflow fix. I am in the process of phasing out the instructions in the readme so I won't update those right now.

jaredwy commented 8 years ago

Thanks! It is a little strange that code that works on windows is failing on mac post compile though. But i can raise a seperate issue if i find it to be the fault of serde.

Thanks for all your help everyone!

dtolnay commented 8 years ago

In #503 I changed serde_codegen to use a 16 MB stack by default even if you do not use thread::spawn in the build script. It is included in serde_codegen 0.8.2.

EDIT: so I removed thread::spawn from the serde.rs setup steps.

jaredwy commented 8 years ago

Good to hear! Glad my frustration was fruitful for others :D