sfackler / rust-postgres

Native PostgreSQL driver for the Rust programming language
Apache License 2.0
3.49k stars 443 forks source link

Segfault #31

Closed jeff-davis closed 9 years ago

jeff-davis commented 10 years ago
extern crate postgres;

use postgres::{PostgresConnection, NoSsl};
use postgres::types::ToSql;

fn main() {
  let mut content : ~str = ~"";
  {
    let conn = PostgresConnection::connect("postgres://jdavis@localhost:5432/postgres", &NoSsl).unwrap();
    let stmt = conn.prepare("SELECT x FROM t").unwrap();
    for row in stmt.query([]).unwrap() {
      let val : i32 = row[1];
      content.push_str(format!("<li>{}</li>\n", val));
    }
  }

  println!("{}", content);
}

Causes a segfault on the rust-nightly package I installed today (rustc 0.10-pre).

Backtrace:

(gdb) bt
#0  0x00007ffff7a9235d in _int_free (av=0x7ffff7dd3740 <main_arena>, p=0x8743a0, have_lock=0) at malloc.c:3924
#1  0x0000000000511ccb in _$UP$$UP$reseeding..ReseedingRng$LT$StdRng$C$TaskRngReseeder$GT$::glue_drop.5898::hca63f8a2631aec80 ()
#2  0x00000000008736d8 in ?? ()
#3  0x00000000005c352b in rt::task::Task::run::closure.41636 ()
#4  0x00000000005c3432 in rt::task::Task::run::closure.41627 ()
#5  0x00000000005ce9fc in rust_try ()
#6  0x00000000005c3282 in rt::task::Task::run::h3233312d889b0104os9::v0.10.pre ()
#7  0x0000000000441ef4 in start::h6478af498774a94fzvd::v0.10.pre ()
#8  0x0000000000441ce4 in lang_start::hdd717b0e84ff646bTud::v0.10.pre ()
#9  0x000000000040664f in main ()
sfackler commented 10 years ago

This is almost certainly a Rust bug. What OS are you on?

sfackler commented 10 years ago

I've filed an issue on what I believe the cause is as mozilla/rust#13246. If you remove the bare block that's wrapping most of that example, everything should run okay.

jeff-davis commented 10 years ago

Ubuntu 13.10 64-bit.

sfackler commented 9 years ago

I believe this should be fixed by rust-lang/rust#21972.