{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/28217","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/28217/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/28217/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/28217/events","html_url":"https://github.com/rust-lang/rust/issues/28217","id":104788860,"number":28217,"title":"thread 'rustc' panicked at 'index out of bounds: [...] src/libcollections/vec.rs:1047","user":{"login":"Mange","id":1599,"avatar_url":"https://avatars.githubusercontent.com/u/1599?v=3","gravatar_id":"","url":"https://api.github.com/users/Mange","html_url":"https://github.com/Mange","followers_url":"https://api.github.com/users/Mange/followers","following_url":"https://api.github.com/users/Mange/following{/other_user}","gists_url":"https://api.github.com/users/Mange/gists{/gist_id}","starred_url":"https://api.github.com/users/Mange/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mange/subscriptions","organizations_url":"https://api.github.com/users/Mange/orgs","repos_url":"https://api.github.com/users/Mange/repos","events_url":"https://api.github.com/users/Mange/events{/privacy}","received_events_url":"https://api.github.com/users/Mange/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-03T21:51:53Z","updated_at":"2015-09-04T15:04:16Z","closed_at":null,"body":"I can't use the `json!` macro on latest `master` (2015-09-03).\r\n\r\n**I tried this code:**\r\n\r\nsrc/main.rs\r\n```rust\r\n#![feature(plugin)]\r\n#![plugin(json_macros)]\r\nextern crate rustc_serialize;\r\n\r\nfn main() {\r\n    let payload = json!({\"test\": \"1\"});\r\n    println!(payload.to_string());\r\n}\r\n```\r\n\r\nCargo.toml:\r\n```toml\r\n[package]\r\n\r\nname = \"rust-bug\"\r\nversion = \"0.0.1\"\r\nauthors = [ \"Magnus Bergmark <magnus.bergmark@gmail.com>\" ]\r\n\r\n[dependencies]\r\njson_macros = \"0.2.5\"\r\nrustc-serialize = \"*\"\r\n```\r\n\r\n```\r\ncargo run\r\n```\r\n\r\n**I expected to see this happen:** `{\"test\":\"1\"}`\r\n\r\n**Instead, this happened:** `note: the compiler unexpectedly panicked. this is a bug.`\r\n\r\n## Meta\r\n\r\n`rustc --version --verbose`:\r\n```\r\nrustc 1.4.0-nightly (9e9c83b89 2015-09-03)\r\nbinary: rustc\r\ncommit-hash: 9e9c83b8994fab4f69fc75838c8c856b57caa5d1\r\ncommit-date: 2015-09-03\r\nhost: x86_64-apple-darwin\r\nrelease: 1.4.0-nightly\r\n```\r\n\r\n`cargo --version`:\r\n```\r\ncargo 0.5.0 (7ea8265 2015-09-03)\r\n```\r\n\r\n**Backtrace:**\r\n\r\n```\r\n› RUST_BACKTRACE=1 cargo run --verbose\r\n       Fresh rustc-serialize v0.3.16\r\n       Fresh json_macros v0.2.5\r\n   Compiling rust-bug v0.0.1 (file:///Users/mange/Desktop/rust-bug)\r\n     Running `rustc src/main.rs --crate-name rust_bug --crate-type bin -g --out-dir /Users/mange/Desktop/rust-bug/target/debug --emit=dep-info,link -L dependency=/Users/mange/Desktop/rust-bug/target/debug -L dependency=/Users/mange/Desktop/rust-bug/target/debug/deps --extern json_macros=/Users/mange/Desktop/rust-bug/target/debug/deps/libjson_macros-588fa665176505c5.dylib --extern rustc_serialize=/Users/mange/Desktop/rust-bug/target/debug/deps/librustc_serialize-7ff5bfc027146194.rlib`\r\nerror: internal compiler error: unexpected panic\r\nnote: the compiler unexpectedly panicked. this is a bug.\r\nnote: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports\r\nthread 'rustc' panicked at 'index out of bounds: the len is 60 but the index is 67', src/libcollections/vec.rs:1047\r\n```\r\n```\r\nstack backtrace:\r\n   1:        0x111149940 - sys::backtrace::tracing::imp::write::hd0176e40ebe71d28Vks\r\n   2:        0x11115191b - panicking::on_panic::h929e7e75bc4f2c31NXw\r\n   3:        0x111113c12 - rt::unwind::begin_unwind_inner::h9d2d49cde66c0c4b0sw\r\n   4:        0x11111499d - rt::unwind::begin_unwind_fmt::h30d162ea92169f156rw\r\n   5:        0x111151527 - rust_begin_unwind\r\n   6:        0x1111925b0 - panicking::panic_fmt::ha85fd08dcab4df5d8PE\r\n   7:        0x11118c710 - panicking::panic_bounds_check::h74acb99379ef18f4ePE\r\n   8:        0x117aba24b - parse::token::InternedString::new_from_name::hf3d5b4c0153b6a85EiT\r\n   9:        0x117bb7014 - parse::parser::Parser<'a>::parse_optional_str::hcbe96d5b0fc32f68b5M\r\n  10:        0x117bb7183 - parse::parser::Parser<'a>::parse_str::h9f9ed6f8c5ab3308o6M\r\n  11:        0x112a0fdfc - plugin::parse_json::closure.10831\r\n  12:        0x112a0f3bd - parse::parser::Parser<'a>::parse_seq_to_before_end::h13189328464236698498\r\n  13:        0x112a0ee2c - parse::parser::Parser<'a>::parse_seq_to_end::h14254503023922733831\r\n  14:        0x1129d35a6 - plugin::parse_json::hfd1a1f8297018b85lba\r\n  15:        0x1129d307e - plugin::expand::h6ee2acb00f38e3fauaa\r\n  16:        0x1157258e9 - ext::base::F.TTMacroExpander::expand::h14210021944373090710\r\n  17:        0x10eee9137 - ext::expand::expand_expr::closure.68004\r\n  18:        0x10eee5f45 - ext::expand::expand_expr::h4484ab514eace144rqb\r\n  19:        0x10ef0ea40 - ext::expand::expand_non_macro_stmt::closure.68390\r\n  20:        0x10ef0e1f0 - ext::expand::expand_non_macro_stmt::closure.68388\r\n  21:        0x10ef0b5a3 - ext::expand::expand_stmt::hbe43f4150453a1b4t7b\r\n  22:        0x10ef3085e - ext::expand::expand_block_elts::closure.68722\r\n  23:        0x10ef305ba - iter::FlatMap<I, U, F>.Iterator::next::h5626001629407774195\r\n  24:        0x10ef2fc77 - vec::Vec<T>.FromIterator<T>::from_iter::h5081602814983063810\r\n  25:        0x10ef2f86f - ext::expand::expand_block_elts::closure.68715\r\n  26:        0x10eef6794 - ext::expand::expand_block_elts::h46bebebd90c7c5fdnic\r\n  27:        0x10ef2f4bd - ext::expand::expand_block::h0a7e72090e4cf398Ihc\r\n  28:        0x10eef6293 - ext::expand::expand_and_rename_fn_decl_and_block::h384c6a1c45a18003wGc\r\n  29:        0x10eefc539 - ext::expand::expand_item_underscore::h8b5990810bd9fc6e4Vb\r\n  30:        0x10ef50f0a - fold::noop_fold_item_simple::h10230394405410749093\r\n  31:        0x10ef50a79 - fold::noop_fold_item::h6703425555223222517\r\n  32:        0x10eefa32a - ext::expand::expand_annotatable::h707bae4d90aeefc9Bsc\r\n  33:        0x10eef6938 - ext::expand::expand_item::h8d338912a8cd204dtVb\r\n  34:        0x10ef02985 - iter::FlatMap<I, U, F>.Iterator::next::h12350997629097857049\r\n  35:        0x10ef0249c - vec::Vec<T>.FromIterator<T>::from_iter::h7763438502537858767\r\n  36:        0x10ef021ca - fold::noop_fold_mod::h6321912319619061707\r\n  37:        0x10eefcdc9 - ext::expand::expand_item_underscore::h8b5990810bd9fc6e4Vb\r\n  38:        0x10ef50f0a - fold::noop_fold_item_simple::h10230394405410749093\r\n  39:        0x10ef50a79 - fold::noop_fold_item::h6703425555223222517\r\n  40:        0x10eefb34e - ext::expand::expand_annotatable::h707bae4d90aeefc9Bsc\r\n  41:        0x10eef6938 - ext::expand::expand_item::h8d338912a8cd204dtVb\r\n  42:        0x10ef5a6b0 - ext::expand::expand_crate::hd42c32144acafe9dkRc\r\n  43:        0x10d62a56a - driver::phase_2_configure_and_expand::closure.27279\r\n  44:        0x10d5bd270 - driver::phase_2_configure_and_expand::h9a043ebdf303a32b3ta\r\n  45:        0x10d5ad050 - driver::compile_input::h277a8ae423a5a9f3Yba\r\n  46:        0x10d711e50 - run_compiler::h9482972dfd518dccbqc\r\n  47:        0x10d70f749 - boxed::F.FnBox<A>::call_box::h12200329393199643738\r\n  48:        0x10d70f142 - rt::unwind::try::try_fn::h12741742821322866078\r\n  49:        0x1111514d8 - __rust_try\r\n  50:        0x11113dcb0 - rt::unwind::try::inner_try::h03cd26bf8e2ee1ceTow\r\n  51:        0x10d70f2f2 - boxed::F.FnBox<A>::call_box::h16465870040843100935\r\n  52:        0x11115084d - sys::thread::Thread::new::thread_start::he62641fb2961f41aBNv\r\n  53:     0x7fff8608f267 - _pthread_body\r\n  54:     0x7fff8608f1e4 - _pthread_start\r\n```\r\n```\r\nCould not compile `rust-bug`.\r\n\r\nCaused by:\r\n  Process didn't exit successfully: `rustc src/main.rs --crate-name rust_bug --crate-type bin -g --out-dir /Users/mange/Desktop/rust-bug/target/debug --emit=dep-info,link -L dependency=/Users/mange/Desktop/rust-bug/target/debug -L dependency=/Users/mange/Desktop/rust-bug/target/debug/deps --extern json_macros=/Users/mange/Desktop/rust-bug/target/debug/deps/libjson_macros-588fa665176505c5.dylib --extern rustc_serialize=/Users/mange/Desktop/rust-bug/target/debug/deps/librustc_serialize-7ff5bfc027146194.rlib` (exit code: 101)\r\n```\r\n\r\n(I broke the output into three so it's more obvious where the backtrace begins and ends.)\r\n\r\n----\r\n\r\nLet me know if there's anything else I can add or try."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/137760750","html_url":"https://github.com/rust-lang/rust/issues/28217#issuecomment-137760750","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/28217","id":137760750,"user":{"login":"christopherdumas","id":1920151,"avatar_url":"https://avatars.githubusercontent.com/u/1920151?v=3","gravatar_id":"","url":"https://api.github.com/users/christopherdumas","html_url":"https://github.com/christopherdumas","followers_url":"https://api.github.com/users/christopherdumas/followers","following_url":"https://api.github.com/users/christopherdumas/following{/other_user}","gists_url":"https://api.github.com/users/christopherdumas/gists{/gist_id}","starred_url":"https://api.github.com/users/christopherdumas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christopherdumas/subscriptions","organizations_url":"https://api.github.com/users/christopherdumas/orgs","repos_url":"https://api.github.com/users/christopherdumas/repos","events_url":"https://api.github.com/users/christopherdumas/events{/privacy}","received_events_url":"https://api.github.com/users/christopherdumas/received_events","type":"User","site_admin":false},"created_at":"2015-09-04T15:04:16Z","updated_at":"2015-09-04T15:04:16Z","body":"Looking at `libcollections/vec.rs:1047`, I noticed that the indexing doesn't seem to be checked. So you could access an index out of bounds, and it would crash (I think):\r\n\r\n```rust\r\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\r\nimpl<T> Index<usize> for Vec<T> {\r\n    type Output = T;\r\n\r\n    #[inline]\r\n    fn index(&self, index: usize) -> &T {\r\n        // NB built-in indexing via `&[T]`\r\n        &(**self)[index]\r\n    }\r\n}\r\n```"}}