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

mpsc queue gives valgrind errors #22762

Closed
diwic opened this issue Feb 24, 2015 · 5 comments
Closed

mpsc queue gives valgrind errors #22762

diwic opened this issue Feb 24, 2015 · 5 comments

Comments

@diwic
Copy link
Contributor

diwic commented Feb 24, 2015

When running the test suite for dbus-rs under valgrind, I get some errors that I don't think is my fault, because there is nothing in the backtrace indicating that would be the case.

Here's an example of that error:

Thread 1:
Conditional jump or move depends on uninitialised value(s)
    at 0x1E9030: sync::mpsc::Receiver$LT$T$GT$::recv::h14764315989133460255
    by 0x1D5D14: run_tests_console::hc794948cddbbd498cOb 
    by 0x1D2524: test_main::h01cefcc5e315671918a
    by 0x1D9CEA: test_main_static::h37e8bff01539d867Hbb
    by 0x1D0DB8: __test::main::hd07f3551eb4cd558Y2e
    by 0x240138: rust_try_inner
    by 0x240125: rust_try
    by 0x23D514: rt::lang_start::h8ce3e548818099f0bSL
    by 0x1D0F04: main
  Uninitialised value was created by a stack allocation
    at 0x1E8457: sync::mpsc::Receiver$LT$T$GT$::recv::h14764315989133460255
@diwic
Copy link
Contributor Author

diwic commented Feb 24, 2015

I tried to nail it but no luck so far. Here's the instruction where it breaks:

   0x00000000001e901e <+3070>:  callq  0x1eaff0 <_ZN4sync4mpsc6shared15Packet$LT$T$GT$8try_recv20h9233234408304405675E>
   0x00000000001e9023 <+3075>:  movzwl 0xde0(%rsp),%eax
   0x00000000001e902b <+3083>:  cmp    $0xff,%eax
=> 0x00000000001e9030 <+3088>:  ja     0x1e9392 <_ZN4sync4mpsc17Receiver$LT$T$GT$4recv21h14764315989133460255E+3954>
   0x00000000001e9036 <+3094>:  movzbl %al,%eax
   0x00000000001e9039 <+3097>:  cmp    $0x1,%eax
   0x00000000001e903c <+3100>:  jne    0x1e9392 <_ZN4sync4mpsc17Receiver$LT$T$GT$4recv21h14764315989133460255E+3954>
   0x00000000001e9042 <+3106>:  lea    0xde0(%rsp),%r12
   0x00000000001e904a <+3114>:  mov    %r12,%rdi
   0x00000000001e904d <+3117>:  callq  0x228790 <_ZN4sync4mpsc8blocking6tokens20hc880a4e85e4c780bbnyE>

And the matching Rust code would be, I believe, in sync/mpsc/shared.rs:

pub fn recv(&mut self) -> Result<T, Failure> {
    // This code is essentially the exact same as that found in the stream
    // case (see stream.rs)
    match self.try_recv() {
        Err(Empty) => {}
        data => return data,
    }

    let (wait_token, signal_token) = blocking::tokens();

...but I don't know enough about Rust's internals to know what the 0xff actually stands for here, that the uninitialised value is compared against?

@mahkoh
Copy link
Contributor

mahkoh commented Feb 24, 2015

Those errors come from cargo and not dbus-rs:

~/dragons$ cargo new hurrdurr
~/dragons$ cd hurrdurr 
~/dragons/hurrdurr$ valgrind cargo build
==8063== Memcheck, a memory error detector
==8063== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==8063== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==8063== Command: cargo build
==8063== 
==8063== Conditional jump or move depends on uninitialised value(s)
==8063==    at 0x3BBDBC: synonym::SynonymMap$LT$K$C$$u20$V$GT$::insert::h3724314155202151280 (in /usr/local/bin/cargo)
==8063==    by 0x3C1FAE: parse::PatParser$LT$$u27$a$GT$::add_atom_ifnotexists::h5c3eddacff495282Glc (in /usr/local/bin/cargo)
==8063==    by 0x3BD0D4: parse::PatParser$LT$$u27$a$GT$::pattern::hf8a955ff6e4a5adet2b (in /usr/local/bin/cargo)
==8063==    by 0x3C1ACE: parse::PatParser$LT$$u27$a$GT$::group::he9c6ce2fbc0887eaimc (in /usr/local/bin/cargo)
==8063==    by 0x3BE266: parse::PatParser$LT$$u27$a$GT$::pattern::hf8a955ff6e4a5adet2b (in /usr/local/bin/cargo)
==8063==    by 0x3B83BC: parse::PatParser$LT$$u27$a$GT$::parse::h90fccbc0b26f2df600b (in /usr/local/bin/cargo)
==8063==    by 0x3B2E7B: parse::Parser::new::h93460f743e7f69d7wsb (in /usr/local/bin/cargo)
==8063==    by 0x1729AC: Docopt::new::h4465346578811968731 (in /usr/local/bin/cargo)
==8063==    by 0x170C42: call_main_without_stdin::h6322948571204322835 (in /usr/local/bin/cargo)
==8063==    by 0x16F80C: main::h14917aa7cb75c12bwca (in /usr/local/bin/cargo)
==8063==    by 0x6A0C18: rust_try_inner (in /usr/local/bin/cargo)
==8063==    by 0x6A0C05: rust_try (in /usr/local/bin/cargo)
==8063== 
==8063== Conditional jump or move depends on uninitialised value(s)
==8063==    at 0x23B64C: ops::cargo_compile::compile_pkg::hbb6f4c5ae72d634apNh (in /usr/local/bin/cargo)
==8063==    by 0x23A827: ops::cargo_compile::compile::h459aef7669fb9faapIh (in /usr/local/bin/cargo)
==8063==    by 0x184512: call_main_without_stdin::h16575523244349200905 (in /usr/local/bin/cargo)
==8063==    by 0x175E15: execute::hecf542bd15794221Ica (in /usr/local/bin/cargo)
==8063==    by 0x171E08: call_main_without_stdin::h6322948571204322835 (in /usr/local/bin/cargo)
==8063==    by 0x16F80C: main::h14917aa7cb75c12bwca (in /usr/local/bin/cargo)
==8063==    by 0x6A0C18: rust_try_inner (in /usr/local/bin/cargo)
==8063==    by 0x6A0C05: rust_try (in /usr/local/bin/cargo)
==8063==    by 0x69DF0C: rt::lang_start::h61cf7984fd279964KzJ (in /usr/local/bin/cargo)
==8063==    by 0x54787FF: (below main) (in /usr/lib/libc-2.21.so)
==8063== 
==8063== Conditional jump or move depends on uninitialised value(s)
==8063==    at 0x2C85ED: sync::mpsc::Receiver$LT$T$GT$::recv::h13638071427880253445 (in /usr/local/bin/cargo)
==8063==    by 0x2467D9: ops::cargo_rustc::compile_targets::haf1e4fe4221dba30P9m (in /usr/local/bin/cargo)
==8063==    by 0x23F0E6: ops::cargo_compile::compile_pkg::hbb6f4c5ae72d634apNh (in /usr/local/bin/cargo)
==8063==    by 0x23A827: ops::cargo_compile::compile::h459aef7669fb9faapIh (in /usr/local/bin/cargo)
==8063==    by 0x184512: call_main_without_stdin::h16575523244349200905 (in /usr/local/bin/cargo)
==8063==    by 0x175E15: execute::hecf542bd15794221Ica (in /usr/local/bin/cargo)
==8063==    by 0x171E08: call_main_without_stdin::h6322948571204322835 (in /usr/local/bin/cargo)
==8063==    by 0x16F80C: main::h14917aa7cb75c12bwca (in /usr/local/bin/cargo)
==8063==    by 0x6A0C18: rust_try_inner (in /usr/local/bin/cargo)
==8063==    by 0x6A0C05: rust_try (in /usr/local/bin/cargo)
==8063==    by 0x69DF0C: rt::lang_start::h61cf7984fd279964KzJ (in /usr/local/bin/cargo)
==8063==    by 0x54787FF: (below main) (in /usr/lib/libc-2.21.so)
==8063== 
==8063== Conditional jump or move depends on uninitialised value(s)
==8063==    at 0x2C3233: ops::cargo_rustc::job_queue::JobQueue$LT$$u27$a$C$$u20$$u27$b$GT$::run::ha0306ea69322c899Fxm (in /usr/local/bin/cargo)
==8063==    by 0x2467AE: ops::cargo_rustc::compile_targets::haf1e4fe4221dba30P9m (in /usr/local/bin/cargo)
==8063==    by 0x23F0E6: ops::cargo_compile::compile_pkg::hbb6f4c5ae72d634apNh (in /usr/local/bin/cargo)
==8063==    by 0x23A827: ops::cargo_compile::compile::h459aef7669fb9faapIh (in /usr/local/bin/cargo)
==8063==    by 0x184512: call_main_without_stdin::h16575523244349200905 (in /usr/local/bin/cargo)
==8063==    by 0x175E15: execute::hecf542bd15794221Ica (in /usr/local/bin/cargo)
==8063==    by 0x171E08: call_main_without_stdin::h6322948571204322835 (in /usr/local/bin/cargo)
==8063==    by 0x16F80C: main::h14917aa7cb75c12bwca (in /usr/local/bin/cargo)
==8063==    by 0x6A0C18: rust_try_inner (in /usr/local/bin/cargo)
==8063==    by 0x6A0C05: rust_try (in /usr/local/bin/cargo)
==8063==    by 0x69DF0C: rt::lang_start::h61cf7984fd279964KzJ (in /usr/local/bin/cargo)
==8063==    by 0x54787FF: (below main) (in /usr/lib/libc-2.21.so)
==8063==

@mahkoh
Copy link
Contributor

mahkoh commented Feb 24, 2015

Well, that's not quite what I meant. The point is that those errors are also in cargo so dbus-rs is probably not the culprit. The error you posted above comes directly from the test framework initialization and not from a test.

@tamird
Copy link
Contributor

tamird commented Nov 8, 2015

Looks like #5856. @alexcrichton?

@alexcrichton
Copy link
Member

Ah yes I believe so, thanks @tamird!

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

5 participants