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

ICE returning unique pointer #2059

Closed
tedhorst opened this issue Mar 28, 2012 · 0 comments
Closed

ICE returning unique pointer #2059

tedhorst opened this issue Mar 28, 2012 · 0 comments
Labels
A-type-system Area: Type system I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@tedhorst
Copy link
Contributor

enum tree<T: copy> { nil, node(~tree<T>, ~tree<T>, T) }

fn tree_init<T: copy>() -> ~tree<T> {
    ~nil
}

fn tree_add<T: copy>(i: T, t: ~tree<T>) -> ~tree<T> {
    t
}

fn main() {
    let atree: ~tree<int> = tree_init();
    let btree = tree_add(1, atree);
    log(debug, btree);
}

This gives:

rust: task 102027e00 ran out of stack
error: internal compiler error unexpected failure

I got the following stack trace from lldb:

* thread #6: tid = 0x2403, 0x0000000100fdc2a4 librustrt.dylib`upcall_fail + 4 at rust_upcall.cpp:129, stop reason = breakpoint 1.1
    frame #0: 0x0000000100fdc2a4 librustrt.dylib`upcall_fail + 4 at rust_upcall.cpp:129
    frame #1: 0x00000001000055d2 rustc`monitor::_7bab36b8b67b44ab + 1634
    frame #2: 0x0000000100006d14 rustc`__morestack + 224
    frame #3: 0x0000000100004f9c rustc`monitor::_7bab36b8b67b44ab + 44
    frame #4: 0x00000001000066ea rustc`main::_6178e9efa23b8931 + 266
    frame #5: 0x0000000100fda1b5 librustrt.dylib`task_start_wrapper(spawn_args*) + 37 at rust_task.cpp:129
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2022
Initial work on Miri permissive-exposed-provenance

Miri portions of the changes for portions of a permissive ptr-to-int model for Miri. This is more restrictive than what we currently have so it will probably need a flag once I figure out how to hook that up.

> This implements a form of permissive exposed-address provenance, wherein the only way to expose the address is with a cast to usize (ideally expose_addr). This is more restrictive than C in that stuff like reading the representation bytes (via unions, type-punning, transmute) does not expose the address, only expose_addr. This is less restrictive than C in that a pointer casted from an integer has union provenance of all exposed pointers, not any udi stuff.

There's a few TODOs here, namely related to `fn memory_read` and friends. We pass it the maybe/unreified provenance before `ptr_get_alloc` reifies it into a concrete one, so it doesn't have the `AllocId` (or the SB tag, but that's getting ahead of ourselves). One way this could be fixed is changing `ptr_get_alloc` and (`ptr_try_get_alloc_id` on the rustc side) to return a pointer with the tag fixed up. We could also take in different arguments, but I'm not sure what works best.

The other TODOs here are how permissive this model could be. This currently does not enforce that a ptr-to-int cast happens before the corresponding int-to-ptr (colloquial meaning of happens before, not atomic meaning). Example:

```
let ptr = 0x2000 as *const i32;
let a: i32 = 5;
let a_ptr = &a as *const i32;

// value is 0x2000;
a_ptr as usize;

println!("{}", unsafe { *ptr }); // this is valid
```

We also allow the resulting pointer to dereference different non-contiguous allocations (the "not any udi stuff" mentioned above), which I'm not sure if is allowed by LLVM.

This is the Miri side of rust-lang#95826.
Kobzol pushed a commit to Kobzol/rust that referenced this issue Dec 30, 2024
bors pushed a commit to rust-lang-ci/rust that referenced this issue Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

2 participants