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

crash: Assertion cx.fcx.llobjfields.contains_key(did.node) failed at src/comp/middle/trans.rs:2914 #1286

Closed
elly opened this issue Dec 13, 2011 · 5 comments

Comments

@elly
Copy link
Contributor

elly commented Dec 13, 2011

The following code crashes rustc f05eaa4 (2011-12-09):

use std;

import std::option;
import std::ptr;
import std::str;
import std::vec;
#[link_name = "pcre"]
native mod _native {
    type _pcre;
    type _pcre_extra;
    fn pcre_exec(re: *_pcre, extra: *_pcre_extra, subject: str::sbuf,
                 length: int, startoffset: int, options: int,
                 ovector: *int, ovecsize: int);
}

obj pcre(_re: *_native::_pcre) {
    fn match(target: str) -> option::t<[str]> unsafe {
        let oveclen = 30;
        let ovec = vec::init_elt_mut::<int>(0, oveclen as uint);
        let ovecp = vec::unsafe::to_ptr::<int>(ovec);
        let r = str::as_buf(target, { |_target|
            _native::pcre_exec(_re, ptr::null(),
                               _target, str::byte_len(target) as int,
                               0, 0, ovecp, oveclen)
        });
        ret option::none;
    }
}

Stack:
(gdb) bt full
#0 upcall_fail (expr=0x5fd750 "Assertion cx.fcx.llobjfields.contains_key(did.node) failed",

file=0x5fd790 "src/comp/middle/trans.rs", line=2914) at ./src/rt/rust_upcall.cpp:65

No locals.
#1 0x0000000000445ef1 in middle::trans::trans_local_var::_adf4c1777aa541de ()

No symbol table info available.
#2 0x00000000004469ac in middle::trans::trans_var::_d1e14f52b7acf547 ()

No symbol table info available.
#3 0x00000000004461b0 in middle::trans::trans_path::_5717eb102c51bae9 ()

No symbol table info available.
#4 0x0000000000448af2 in middle::trans::trans_lval::_1f6f126aa370757e ()

No symbol table info available.
#5 0x0000000000450c41 in middle::trans::trans_temp_lval::_1f6f126aa370757e ()

No symbol table info available.
#6 0x000000000044ca53 in middle::trans::trans_arg_expr::_f2ab945cefa5f446 ()

No symbol table info available.
#7 0x000000000044dde0 in middle::trans::trans_args::_5b185ed913f17816 ()

No symbol table info available.
#8 0x000000000044e1ea in middle::trans::trans_call::_9bc861feeed3fbef ()

No symbol table info available.
#9 0x0000000000451be9 in middle::trans::trans_expr::_e7480723aeaebdfe ()

No symbol table info available.
#10 0x000000000045873b in middle::trans::trans_block_dps::_95df69d395a561cc ()

No symbol table info available.
#11 0x000000000045a884 in middle::trans::trans_closure::_5f30b7b117e0c7c7 ()

No symbol table info available.
#12 0x000000000043e92e in middle::trans::trans_expr_fn::_9276f38be3371c81 ()

No symbol table info available.
#13 0x0000000000451ace in middle::trans::trans_expr::_e7480723aeaebdfe ()

No symbol table info available.
#14 0x0000000000450b1c in middle::trans::trans_expr_save_in::_58e068603372c187 ()

No symbol table info available.
#15 0x0000000000451093 in middle::trans::trans_temp_lval::_1f6f126aa370757e ()

No symbol table info available.
#16 0x000000000044ca53 in middle::trans::trans_arg_expr::_f2ab945cefa5f446 ()

No symbol table info available.
#17 0x000000000044dde0 in middle::trans::trans_args::_5b185ed913f17816 ()

No symbol table info available.
#18 0x000000000044e1ea in middle::trans::trans_call::_9bc861feeed3fbef ()

No symbol table info available.
#19 0x0000000000451be9 in middle::trans::trans_expr::_e7480723aeaebdfe ()

No symbol table info available.
#20 0x0000000000450eea in middle::trans::trans_temp_lval::_1f6f126aa370757e ()

No symbol table info available.
#21 0x000000000045624b in middle::trans::init_local::_6fb0f262f37ff83d ()

No symbol table info available.
#22 0x0000000000456dc2 in middle::trans::trans_stmt::_c6405279a5bafb3f ()

No symbol table info available.
#23 0x00000000004584df in middle::trans::trans_block_dps::_95df69d395a561cc ()

No symbol table info available.
#24 0x000000000045a884 in middle::trans::trans_closure::_5f30b7b117e0c7c7 ()

No symbol table info available.
#25 0x000000000045ab8b in middle::trans::trans_fn::_3faad8b8f452ee78 ()

No symbol table info available.
#26 0x00000000004848a1 in middle::trans_objects::process_normal_mthd::_58e8157eea4a94d2 ()

No symbol table info available.
#27 0x0000000000480b2d in middle::trans_objects::create_vtbl::_2bedb929f9a5e9c4 ()

No symbol table info available.
#28 0x000000000047bceb in middle::trans_objects::trans_obj::_fcc8a3a1f08fa3a2 ()

No symbol table info available.
#29 0x000000000045f81f in middle::trans::trans_item::_736b03787cae8654 ()

No symbol table info available.
#30 0x0000000000469778 in middle::trans::trans_crate::_5e8b9ab58c8b592f ()

No symbol table info available.
#31 0x00000000005f3df0 in driver::rustc::compile_input::thunk9162 ()

No symbol table info available.
#32 0x00000000005a6998 in driver::rustc::time::_3e691b2a4ba58aee ()

No symbol table info available.
#33 0x00000000005a94dd in driver::rustc::compile_input::_7475af45dcc3eb6c ()

No symbol table info available.
#34 0x00000000005b10ef in driver::rustc::main::_cd8b8c8185af3dee ()

No symbol table info available.
#35 0x00007ffff601e306 in task_start_wrapper (a=0x7ffff511f014) at ./src/rt/rust_task.cpp:176

    task = 0x8c1cc0
    rval = 42
    failed = false
    env = <optimized out>

#36 0x00000000deadbeef in ?? ()

No symbol table info available.
#37 0x008c1cc000000000 in ?? ()

No symbol table info available.
#38 0x0000000000000000 in ?? ()

No symbol table info available.

I have not tried reproducing with HEAD yet as HEAD does not build for me right now.

@lht
Copy link
Contributor

lht commented Dec 13, 2011

This can be reduced to: (reproduced on trunk)

use std;
import std::str;
obj pcre(_re: int) {
  fn match(target: str) {
    str::as_buf(target, { |_target|
        _re
    });
  }
}

@graydon
Copy link
Contributor

graydon commented Dec 13, 2011

Probably the block trying to access the obj field as an upvar

@erickt
Copy link
Contributor

erickt commented Dec 15, 2011

I found a workaround for this. If you pull the block out of the object it compiles:

use std;
import std::str;
obj pcre(_re: int) {
  fn match(target: str) {
    _match(_re, target)
  }
}
fn _match(_re: int, target: str) {
  str::as_buf(target, { |_target|
    _re
  });
}

@nikomatsakis
Copy link
Contributor

Simpler workaround: store the field into a local variable.

use std;
import std::str;
obj pcre(_re: int) {
  fn match(target: str) {
    let re = _re;
    str::as_buf(target, { |_target|
        re
    });
  }
}

@marijnh
Copy link
Contributor

marijnh commented Jan 13, 2012

I assume removing objs will have 'fixed' this.

@marijnh marijnh closed this as completed Jan 13, 2012
coastalwhite pushed a commit to coastalwhite/rust that referenced this issue Aug 5, 2023
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

6 participants