Skip to content

Segfault in safe code while decoding JSON #16121

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

Closed
japaric opened this issue Jul 30, 2014 · 2 comments
Closed

Segfault in safe code while decoding JSON #16121

japaric opened this issue Jul 30, 2014 · 2 comments

Comments

@japaric
Copy link
Member

japaric commented Jul 30, 2014

STR

extern crate serialize;

use serialize::json;

#[deriving(Decodable)]
struct Interpreter {
    command: String,
    flags: Vec<String>,
    version: String,
}

static GOOD_INPUT: &'static str =
r#"{
    "command": "python3",
    "flags": ["-O"],
    "version": "--version"
}"#;

static BAD_INPUT: &'static str =
r#"{
    "command": "python3",
    "flags": ["-O"],
    "--version": "--version"
}"#;

fn main() {
    println!("Decoding GOOD_INPUT... ");
    let good = match json::decode::<Interpreter>(GOOD_INPUT) {
        Err(err) => fail!("{}", err),
        Ok(interpreter) => interpreter,
    };
    println!("> OK");

    println!("Decoding BAD_INPUT... ");
    let bad = match json::decode::<Interpreter>(BAD_INPUT) {
        Err(err) => fail!("{}", err),
        Ok(interpreter) => interpreter,
    };
    println!("> OK");
}

GDB backtrace:

Decoding GOOD_INPUT...
> OK
Decoding BAD_INPUT...

Program received signal SIGSEGV, Segmentation fault.
0x0000000000404696 in json::decode::h14338055721627637230 ()
(gdb) backtrace
#0  0x0000000000404696 in json::decode::h14338055721627637230 ()
#1  0x0000000000403a38 in main::ha45ff07edb6cb131oca ()
#2  0x00000000004416a3 in start::closure.$x22closure$x22$LP$8257$RP$ ()
#3  0x000000000046b76c in rust_try ()
#4  0x0000000000468ca7 in unwind::try::h7df958a05de7d0830Ld ()
#5  0x0000000000468a97 in task::Task::run::h7e40d178364b7983WTc ()
#6  0x00000000004414c0 in start::h00c9cf36f68b5235Ype ()
#7  0x00000000004412f9 in lang_start::h69b9bfc9bbd58be9ipe ()
#8  0x00007ffff7415fd0 in __libc_start_main () from /lib64/libc.so.6
#9  0x00000000004037a1 in _start ()

Version:

rustc 0.12.0-pre (3ab170ffc 2014-07-30 13:01:10 +0000)

(It also segfaults in the playpen)

cc @erickt

@sfackler
Copy link
Member

Could be #15763

@luqmana
Copy link
Member

luqmana commented Jul 31, 2014

Yep, closing as dupe of #15763.

@luqmana luqmana closed this as completed Jul 31, 2014
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