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

Using std::unstable::intrinsics::uninit() causes voidBroken module found #10714

Closed
colemickens opened this issue Nov 29, 2013 · 2 comments
Closed
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@colemickens
Copy link
Contributor

I modified some code from this

let filter_program: bpf_program;
if handle == ptr::null() {
    None
} else {
    pcap_lookupnet(dev, &netp, &maskp, eb);
    let res = pcap_compile(handle, &filter_program, filter_str, 0, &netp);
    [...]
}

to this:

let filter_program: bpf_program = std::unstable::intrinsics::uninit();
if handle == ptr::null() {
    None
} else {
    pcap_lookupnet(dev, &netp, &maskp, eb);
    let res = pcap_compile(handle, &filter_program, filter_str, 0, &netp);
    [...]
}

to attempt to avoid: "error: use of possibly uninitialized variable: filter_program" as per @cmr's suggestion.

Now the compiler is telling me:

Found return instr that returns non-void in Function of void return type!
  ret %"enum.rustpcap::bpf_program" undef
 voidBroken module found, compilation aborted!
Stack dump:
0.      Running pass 'Module Verifier' on function '@_ZN8unstable10intrinsics6uninit19hb2289098237644e0az4v0.0E'
[1]    2448 abort (core dumped)  rustc main.rs
@colemickens
Copy link
Contributor Author

enum v {}
fn main() {
    let y: v = unsafe { std::unstable::intrinsics::uninit() };
}

is apparently a simpler repro case.

@alexcrichton
Copy link
Member

This appears to be fixed now, flagging needstest

alexcrichton added a commit to alexcrichton/rust that referenced this issue Feb 3, 2014
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. 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

2 participants