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

'assertion failed: rp.is_none()' during compile #7400

Closed
dcolish opened this issue Jun 26, 2013 · 7 comments
Closed

'assertion failed: rp.is_none()' during compile #7400

dcolish opened this issue Jun 26, 2013 · 7 comments
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@dcolish
Copy link

dcolish commented Jun 26, 2013

Code to produce

pub mod bits {
    use std::vec;
    use std::uint;

    struct BitVector<'self> {
        v: &'self [u8]
    }

    pub fn new(n: u64) -> BitVector<'self> {
        let f = vec::with_capacity::<u8>(n);
        BitVector {
            v: f
        }
    }
}


fn main() {
    let f = bits::new(10);
}

Backtrace is here https://gist.github.com/5864573

@Aatch
Copy link
Contributor

Aatch commented Jun 26, 2013

@dcolish So it's a valid issue, (I haven't checked for duplicates yet), but that code shouldn't compile anyway.

struct BitVector<'self> {
    v: &'self [u8]
}

That struct is defined to contain a slice that lasts for atleast as long as the struct itself. This is perfectly valid. However, this is wrong (explanation inline):

pub fn new(n: u64) -> BitVector<'self> {
    // So this constructs a ~[u8] and assigns it to 'f'
    let f = vec::with_capacity::<u8>(n);
    // This constructs 'BitVector' and gives it 'f', since 'f' is a ~[u8] and
    // 'v' is a &[u8], 'f' is "auto-sliced" when you assign it like this.
    BitVector {
        v: f
    }
    // This is where the lifetime of 'f' ends, since slicing it doesn't move it,
    // the lifetime ends here and the vector is freed.
    // Since you are returning a pointer to that vector, this would mean that
    // BitVector contains a dangling pointer. If it compiled this would be a use-
    // after-free error, something lifetimes are supposed to prevent.
}

cc'ing @nikomatsakis

@eevee
Copy link

eevee commented Jul 19, 2013

I bumbled across this as well; the problem seems to be that the <'self> is missing from after the function name.

@jdm
Copy link
Contributor

jdm commented Jul 19, 2013

Minimal testcase:

pub trait NodeBase<'self> {
    pub fn base_node(&'self self) -> &'self int;
}

pub fn create<'self, T: NodeBase<'self>>(node: &'self mut T) {
}

fn main() {
}
Breakpoint 1, rust_task_fail (task=0x7ffff0204790, expr=0x7fffe84a41a0 "assertion failed: rp.is_none()", file=0x7ffff7114570 <str59342> "/home/jdm/sdb/rust/src/librustc/middle/typeck/collect.rs", line=1066)
    at /home/jdm/sdb/rust/src/rt/rust_task.cpp:91
warning: Source file is more recent than executable.
91      task->begin_failure(expr, file, line);
Missing separate debuginfos, use: debuginfo-install glibc-2.16-33.fc18.x86_64 libgcc-4.7.2-8.fc18.x86_64 libstdc++-4.7.2-8.fc18.x86_64
(gdb) bt
#0  rust_task_fail (task=0x7ffff0204790, expr=0x7fffe84a41a0 "assertion failed: rp.is_none()", file=0x7ffff7114570 <str59342> "/home/jdm/sdb/rust/src/librustc/middle/typeck/collect.rs", line=1066)
    at /home/jdm/sdb/rust/src/rt/rust_task.cpp:91
#1  0x00007ffff65907f9 in __morestack () from /usr/local/bin/../lib/librustrt.so
#2  0x00007ffff6581aa0 in call_on_c_stack (fn_ptr=0x7ffff65813e0 <upcall_s_fail(s_fail_args*)>, args=0x7ffff46c34f0, this=0x7ffff0204790) at /home/jdm/sdb/rust/src/rt/rust_task.h:481
#3  call_upcall_on_c_stack (fn_ptr=0x7ffff65813e0 <upcall_s_fail(s_fail_args*)>, args=0x7ffff46c34f0, task=<optimized out>) at /home/jdm/sdb/rust/src/rt/rust_upcall.cpp:51
#4  upcall_fail (expr=<optimized out>, file=0x7ffff7114570 <str59342> "/home/jdm/sdb/rust/src/librustc/middle/typeck/collect.rs", line=1066) at /home/jdm/sdb/rust/src/rt/rust_upcall.cpp:134
#5  0x00007ffff7d29103 in sys::begin_unwind_::_615cb041c655a97::_07pre () from /usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.7-pre.so
#6  0x00007ffff7d29092 in sys::__extensions__::fail_with::anon::anon::expr_fn_20105 () from /usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.7-pre.so
#7  0x00007ffff7c6902b in sys::__extensions__::meth_9151::fail_with::_ac9eb45dc42bd690::_07pre () from /usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.7-pre.so
#8  0x00007ffff6c8bb0d in middle::typeck::collect::ty_of_item::_af587f345880ea15::_07pre () from /usr/local/bin/../lib/librustc-c84825241471686d-0.7-pre.so
#9  0x00007ffff6c8698b in middle::typeck::collect::convert::_d0cba369a739ab4::_07pre () from /usr/local/bin/../lib/librustc-c84825241471686d-0.7-pre.so
#10 0x00007ffff6c8636b in middle::typeck::collect::collect_item_types::anon::expr_fn_59405 () from /usr/local/bin/../lib/librustc-c84825241471686d-0.7-pre.so
#11 0x00007ffff7405ae6 in visit::mk_simple_visitor::anon::expr_fn_17109 () from /usr/local/bin/../lib/libsyntax-84efebcb12c867a2-0.7-pre.so
#12 0x00007ffff74050ca in visit::mk_simple_visitor::anon::expr_fn_17099 () from /usr/local/bin/../lib/libsyntax-84efebcb12c867a2-0.7-pre.so
#13 0x00007ffff6890ae1 in visit::visit_crate_34001::_a964efa1e9ab4f6::_07pre () from /usr/local/bin/../lib/librustc-c84825241471686d-0.7-pre.so
#14 0x00007ffff6c8449e in middle::typeck::collect::collect_item_types::_3ba31b1c9b8b1891::_07pre () from /usr/local/bin/../lib/librustc-c84825241471686d-0.7-pre.so
#15 0x00007ffff6cdedd2 in middle::typeck::check_crate::anon::expr_fn_60938 () from /usr/local/bin/../lib/librustc-c84825241471686d-0.7-pre.so
#16 0x00007ffff6cdec29 in util::common::time_60929::_a6aa6673bcdf8f66::_07pre () from /usr/local/bin/../lib/librustc-c84825241471686d-0.7-pre.so
#17 0x00007ffff6cdc1f0 in middle::typeck::check_crate::_4387c6ff27b03d::_07pre () from /usr/local/bin/../lib/librustc-c84825241471686d-0.7-pre.so
#18 0x00007ffff6fe349d in driver::driver::compile_rest::_134f5496ff5de1::_07pre () from /usr/local/bin/../lib/librustc-c84825241471686d-0.7-pre.so
#19 0x00007ffff6fe9682 in driver::driver::compile_upto::_747e21c0469b22f2::_07pre () from /usr/local/bin/../lib/librustc-c84825241471686d-0.7-pre.so
#20 0x00007ffff6fe9b07 in driver::driver::compile_input::_0b1e5b3afc4cd1::_07pre () from /usr/local/bin/../lib/librustc-c84825241471686d-0.7-pre.so
#21 0x00007ffff701a32b in run_compiler::_63c0a0c62771367c::_07pre () from /usr/local/bin/../lib/librustc-c84825241471686d-0.7-pre.so
#22 0x00007ffff702d00e in main::anon::expr_fn_89809 () from /usr/local/bin/../lib/librustc-c84825241471686d-0.7-pre.so
#23 0x00007ffff702a8fc in monitor::anon::expr_fn_89630 () from /usr/local/bin/../lib/librustc-c84825241471686d-0.7-pre.so
#24 0x00007ffff70242cc in task::__extensions__::try_89033::anon::expr_fn_89226 () from /usr/local/bin/../lib/librustc-c84825241471686d-0.7-pre.so
#25 0x00007ffff702d2e8 in __morestack () from /usr/local/bin/../lib/librustc-c84825241471686d-0.7-pre.so
#26 0x00007ffff7cf2045 in task::spawn::spawn_raw_oldsched::make_child_wrapper::anon::expr_fn_17074 () from /usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.7-pre.so
#27 0x00007ffff7d6e898 in __morestack () from /usr/local/bin/../lib/libcore-c3ca5d77d81b46c1-0.7-pre.so
#28 0x00007ffff6580414 in task_start_wrapper (a=0x7ffff0205750) at /home/jdm/sdb/rust/src/rt/rust_task.cpp:167
#29 0x0000000000000000 in ?? ()

@alexcrichton
Copy link
Member

Closed by #10153, relevant tests already appear to be checked in.

@nikomatsakis
Copy link
Contributor

Closed by #10153, relevant tests already appear to be checked in.

Are the tests enabled? I didn't check them in, at least.

@alexcrichton
Copy link
Member

I was specifically referencing https://github.com/mozilla/rust/blob/master/src/test/compile-fail/regions-undeclared.rs because this is just using an undeclared region. That being said, you know far more about this than I do, so I'll stick to just flagging as needstest for now.

@alexcrichton alexcrichton reopened this Nov 11, 2013
@nikomatsakis
Copy link
Contributor

I don't think a special test is needed, there are tests target the named lifetime resolver.

flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 1, 2021
New lint: `disallowed_script_idents`

This PR implements a new lint to restrict locales that can be used in the code,
as proposed in rust-lang#7376.

Current concerns / unresolved questions:

- ~~Mixed usage of `script` (as a Unicode term) and `locale` (as something that is easier to understand for the broad audience). I'm not sure whether these terms are fully interchangeable and whether in the current form it is more confusing than helpful.~~ `script` is now used everywhere.
- ~~Having to mostly copy-paste `AllowedScript`. Probably it's not a big problem, as the list of scripts is standardized and is unlikely to change, and even if we'd stick to the `unicode_script::Script`, we'll still have to implement custom deserialization, and I don't think that it will be shorter in terms of the amount of LoC.~~ `unicode::Script` is used together with a filtering deserialize function.
- Should we stick to the list of "recommended scripts" from [UAX rust-lang#31](http://www.unicode.org/reports/tr31/#Table_Recommended_Scripts) in the configuration?

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: ``[`disallowed_script_idents`]``

r? `@Manishearth`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

6 participants