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

use_after_free issue with nightly #7

Closed
nugend opened this issue Dec 1, 2018 · 6 comments
Closed

use_after_free issue with nightly #7

nugend opened this issue Dec 1, 2018 · 6 comments

Comments

@nugend
Copy link

nugend commented Dec 1, 2018

I believe my solution for day 1 is correct here, but I'm seeing the following when cargo runing

$ cargo run
   Compiling advent-of-code-2018 v0.1.0 (/Users/danno/code/advent-of-code-2018)
thread 'main' panicked at 'use-after-free in `proc_macro` handle', src/libcore/option.rs:1008:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: custom attribute panicked
 --> src/day_1.rs:8:1
  |
8 | #[aoc(day1, part1)]
  | ^^^^^^^^^^^^^^^^^^^
  |
  = help: message: use-after-free in `proc_macro` handle

error: aborting due to previous error

error: Could not compile `advent-of-code-2018`.

To learn more, run the command again with --verbose.

Here's the BT:

$ RUST_BACKTRACE=1 cargo run
   Compiling advent-of-code-2018 v0.1.0 (/Users/danno/code/advent-of-code-2018)
thread 'main' panicked at 'use-after-free in `proc_macro` handle', src/libcore/option.rs:1008:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::continue_panic_fmt
   7: rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::option::expect_failed
  10: <proc_macro::bridge::TokenTree<G, P, I, L> as proc_macro::bridge::rpc::DecodeMut<'a, '_, S>>::decode
  11: std::panicking::try::do_call
  12: __rust_maybe_catch_panic
  13: <proc_macro::bridge::server::Dispatcher<proc_macro::bridge::server::MarkedTypes<S>> as proc_macro::bridge::server::DispatcherTrait>::dispatch
  14: <proc_macro::bridge::closure::Closure<'a, A, R> as core::convert::From<&'a mut F>>::from::call
  15: <proc_macro::bridge::closure::Closure<'a, A, R> as core::convert::From<&'a mut F>>::from::call
  16: proc_macro::diagnostic::Diagnostic::emit::to_internal
             at src/libproc_macro/bridge/closure.rs:40
             at src/libproc_macro/bridge/client.rs:243
             at src/libproc_macro/bridge/client.rs:327
             at src/libproc_macro/bridge/client.rs:292
             at src/libproc_macro/bridge/scoped_cell.rs:83
             at src/libproc_macro/bridge/client.rs:290
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libstd/thread/local.rs:309
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libstd/thread/local.rs:255
             at src/libproc_macro/bridge/client.rs:289
             at src/libproc_macro/bridge/client.rs:320
             at src/libproc_macro/bridge/client.rs:236
             at src/libproc_macro/lib.rs:148
  17: core::clone::impls::<impl core::clone::Clone for usize>::clone
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libcore/convert.rs:455
  18: proc_macro2::imp::nightly_works::{{closure}}
             at /Users/danno/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-0.4.24/src/unstable.rs:179
  19: <proc_macro::TokenStream as core::clone::Clone>::clone
             at /Users/danno/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-0.4.24/src/unstable.rs:248
  20: <proc_macro::TokenStream as core::clone::Clone>::clone
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libcore/ops/function.rs:286
  21: <core::str::Bytes<'_> as core::iter::iterator::Iterator>::next
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libcore/option.rs:424
  22: <core::str::Bytes<'_> as core::iter::iterator::Iterator>::next
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libcore/iter/mod.rs:1328
  23: <core::str::Bytes<'_> as core::iter::iterator::Iterator>::next
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libcore/iter/mod.rs:799
  24: <proc_macro2::TokenStream as core::clone::Clone>::clone
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libproc_macro/lib.rs:171
  25: <core::str::Bytes<'_> as core::iter::iterator::Iterator>::next
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libcore/iter/iterator.rs:1477
  26: <proc_macro2::TokenStream as core::clone::Clone>::clone
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libproc_macro/lib.rs:189
  27: <proc_macro::TokenStream as core::clone::Clone>::clone
             at /Users/danno/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-0.4.24/src/unstable.rs:245
  28: <alloc::vec::SetLenOnDrop<'a> as core::ops::drop::Drop>::drop
             at /Users/danno/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-0.4.24/src/lib.rs:170
  29: <proc_macro2::TokenStream as core::clone::Clone>::clone
             at /Users/danno/.cargo/registry/src/github.com-1ecc6299db9ec823/quote-0.6.10/src/ext.rs:41
  30: <proc_macro2::TokenStream as core::clone::Clone>::clone
             at /Users/danno/.cargo/registry/src/github.com-1ecc6299db9ec823/quote-0.6.10/src/to_tokens.rs:173
  31: <&'a T as quote::to_tokens::ToTokens>::to_tokens
             at /Users/danno/.cargo/registry/src/github.com-1ecc6299db9ec823/quote-0.6.10/src/to_tokens.rs:77
  32: aoc_runner_derive::runner::runner_impl::{{closure}}
             at /Users/danno/.cargo/registry/src/github.com-1ecc6299db9ec823/aoc-runner-derive-0.1.3/src/runner.rs:49
  33: <std::thread::local::LocalKey<T>>::try_with
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libstd/thread/local.rs:309
  34: <std::thread::local::LocalKey<T>>::with
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libstd/thread/local.rs:255
  35: aoc_runner_derive::runner::runner_impl
             at /Users/danno/.cargo/registry/src/github.com-1ecc6299db9ec823/aoc-runner-derive-0.1.3/src/runner.rs:29
  36: aoc_runner_derive::aoc
             at /Users/danno/.cargo/registry/src/github.com-1ecc6299db9ec823/aoc-runner-derive-0.1.3/src/lib.rs:44
  37: std::panicking::try::do_call
             at src/libproc_macro/bridge/client.rs:419
             at src/libproc_macro/bridge/scoped_cell.rs:88
             at src/libproc_macro/bridge/scoped_cell.rs:83
             at src/libproc_macro/bridge/scoped_cell.rs:88
             at src/libproc_macro/bridge/client.rs:316
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libstd/thread/local.rs:309
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libstd/thread/local.rs:255
             at src/libproc_macro/bridge/client.rs:316
             at src/libproc_macro/bridge/client.rs:411
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libstd/panic.rs:319
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libstd/panicking.rs:310
  38: panic_unwind::dwarf::eh::read_encoded_pointer
             at src/libpanic_unwind/lib.rs:102
  39: proc_macro::bridge::client::<impl proc_macro::bridge::Bridge<'_>>::enter::{{closure}}::{{closure}}
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libstd/panicking.rs:289
             at /rustc/d09466ceb1374bd0ff1c490bfd50133b8ca67558/src/libstd/panic.rs:398
             at src/libproc_macro/bridge/client.rs:410
  40: proc_macro::bridge::server::run_server
  41: <syntax_ext::proc_macro_impl::AttrProcMacro as syntax::ext::base::AttrProcMacro>::expand
  42: syntax::ext::expand::MacroExpander::expand_invoc
  43: syntax::ext::expand::MacroExpander::expand_fragment
  44: syntax::ext::expand::MacroExpander::expand_crate
  45: rustc_driver::driver::phase_2_configure_and_expand_inner::{{closure}}
  46: rustc::util::common::time
  47: rustc_driver::driver::phase_2_configure_and_expand
  48: rustc_driver::driver::compile_input
  49: rustc_driver::run_compiler_with_pool
  50: <scoped_tls::ScopedKey<T>>::set
  51: rustc_driver::run_compiler
  52: rustc_driver::monitor::{{closure}}
  53: __rust_maybe_catch_panic
  54: rustc_driver::run
  55: rustc_driver::main
  56: std::rt::lang_start::{{closure}}
  57: std::panicking::try::do_call
  58: __rust_maybe_catch_panic
  59: std::rt::lang_start_internal
  60: main
query stack during panic:
end of query stack
error: custom attribute panicked
 --> src/day_1.rs:8:1
  |
8 | #[aoc(day1, part1)]
  | ^^^^^^^^^^^^^^^^^^^
  |
  = help: message: use-after-free in `proc_macro` handle

error: aborting due to previous error

error: Could not compile `advent-of-code-2018`.

To learn more, run the command again with --verbose.

@gobanos
Copy link
Owner

gobanos commented Dec 1, 2018

Thanks for reporting !

I have reproduce the issue on last nightly, I had a different message with a 2-3 day old one.

I'll check that :)

@gobanos
Copy link
Owner

gobanos commented Dec 1, 2018

Ok, made some progress.

proc_macro is under refactor, see https://github.com/rust-lang/rust/tree/master/src/libproc_macro.

I'm not sure if it's a bug or an expected behavior (at least it should fail to compile aoc-runner-derive crate...), so I will open an issue, and recommend you to use an older nightly build.

PS : issue link

@jfredett
Copy link

jfredett commented Dec 1, 2018

I'm working my way through recent nightlies (I'm also seeing this problem on most recent nightly), but I'm getting a different issue.

≈≈≈ cargo build
    Blocking waiting for file lock on build directory
   Compiling aoc-runner v0.1.0
   Compiling advent-2018 v0.1.0 (/home/jfredett/code/rust/advent-2018)
error[E0432]: unresolved import `Factory`
  --> src/day1.rs:12:1
   |
12 | #[aoc(day1, part1)]
   | ^^^^^^^^^^^^^^^^^^^ no `Factory` external crate

error: aborting due to previous error

This happens on 2018-11-25 nightly, I'm still working my way through the others, but I'm wondering if my setup is just wrong?

here's my day1.rs from whence the above error comes:

pub type SignalChain = Vec<i64>;

#[aoc_generator(day1)]
pub fn input_generator(input: &str) -> SignalChain {
   // snip
}

#[aoc(day1, part1)]
pub fn solution(input: &str) -> i32 {
    // snip
}

I haven't really got to use the framework much (trying to work through the issues getting it to run), so it may just be that I'm doing something wrong/missing some use?

@gobanos
Copy link
Owner

gobanos commented Dec 1, 2018

@jfredett Looks like you are using edition 2018 with an older version of aoc-runner-derive.

This issue should be solve in 0.1.3.

@jfredett
Copy link

jfredett commented Dec 1, 2018

That did it, I can confirm that the nightly-2018-11-30 works as expected as a workaround for this issue.

@gobanos
Copy link
Owner

gobanos commented Dec 1, 2018

I just published aoc-runner-derive 0.1.4, which solves this problem !

@gobanos gobanos closed this as completed Dec 1, 2018
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

3 participants