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

Broken LLVM function when pushing dyn* item to Vec. #102141

Closed
Tracked by #102425
mejrs opened this issue Sep 22, 2022 · 2 comments · Fixed by #104338
Closed
Tracked by #102425

Broken LLVM function when pushing dyn* item to Vec. #102141

mejrs opened this issue Sep 22, 2022 · 2 comments · Fixed by #104338
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. F-dyn_star `#![feature(dyn_star)]` requires-nightly This issue requires a nightly compiler in some way.

Comments

@mejrs
Copy link
Contributor

mejrs commented Sep 22, 2022

Playground

Code

#![feature(dyn_star)]
#![allow(incomplete_features)]

use core::fmt::Debug;

fn main() {
    let mut v = vec![];
    let i = 42_u8 as dyn* Debug;
    v.push(i);
}

Result:

Call parameter type does not match function signature!
i8 42
 i64  invoke void @"_ZN5alloc3vec16Vec$LT$T$C$A$GT$4push17h57979dab0e1643c2E"(ptr align 8 %3, i8 42, ptr align 8 @6)
          to label  unwind label %8, !dbg !2675
in function _ZN10playground4main17h68903ee09fbec9bcE
LLVM ERROR: Broken function found, compilation aborted!

Meta

1.66.0-nightly (2022-09-21 9062b780b32d2eab060b)

@rustbot label: F-dyn_star requires-nightly A-LLVM

@mejrs mejrs added the C-bug Category: This is a bug. label Sep 22, 2022
@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. F-dyn_star `#![feature(dyn_star)]` requires-nightly This issue requires a nightly compiler in some way. labels Sep 22, 2022
@matthiaskrgr
Copy link
Member

Miri actually reports this as a bug :)

error: Undefined Behavior: scalar size mismatch: expected 8 bytes but got 1 bytes instead
 --> src/main.rs:8:13
  |
8 |     let i = 42_u8 as dyn* Debug;
  |             ^^^^^^^^^^^^^^^^^^^ scalar size mismatch: expected 8 bytes but got 1 bytes instead
  |
  = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
  = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
  = note: BACKTRACE:
  = note: inside `main` at src/main.rs:8:13

@compiler-errors
Copy link
Member

FYI: We currently have 0 checks that dyn* actually fit their size requirement currently.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 16, 2022
…holk

Enforce that `dyn*` coercions are actually pointer-sized

Implement a perma-unstable, rudimentary `PointerSized` trait to enforce `dyn*` casts are `usize`-sized for now, at least to prevent ICEs and weird codegen issues from cropping up after monomorphization since currently we enforce *nothing*.

This probably can/should be removed in favor of a more sophisticated trait for handling `dyn*` conversions when we decide on one, but I just want to get something up for discussion and experimentation for now.

r? `@eholk` cc `@tmandry` (though feel free to claim/reassign)

Fixes rust-lang#102141
Fixes rust-lang#102173
Manishearth added a commit to Manishearth/rust that referenced this issue Nov 18, 2022
…holk

Enforce that `dyn*` coercions are actually pointer-sized

Implement a perma-unstable, rudimentary `PointerSized` trait to enforce `dyn*` casts are `usize`-sized for now, at least to prevent ICEs and weird codegen issues from cropping up after monomorphization since currently we enforce *nothing*.

This probably can/should be removed in favor of a more sophisticated trait for handling `dyn*` conversions when we decide on one, but I just want to get something up for discussion and experimentation for now.

r? `@eholk` cc `@tmandry` (though feel free to claim/reassign)

Fixes rust-lang#102141
Fixes rust-lang#102173
Manishearth added a commit to Manishearth/rust that referenced this issue Nov 18, 2022
…holk

Enforce that `dyn*` coercions are actually pointer-sized

Implement a perma-unstable, rudimentary `PointerSized` trait to enforce `dyn*` casts are `usize`-sized for now, at least to prevent ICEs and weird codegen issues from cropping up after monomorphization since currently we enforce *nothing*.

This probably can/should be removed in favor of a more sophisticated trait for handling `dyn*` conversions when we decide on one, but I just want to get something up for discussion and experimentation for now.

r? ``@eholk`` cc ``@tmandry`` (though feel free to claim/reassign)

Fixes rust-lang#102141
Fixes rust-lang#102173
@bors bors closed this as completed in 24ee599 Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. F-dyn_star `#![feature(dyn_star)]` requires-nightly This issue requires a nightly compiler in some way.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants