Skip to content
This repository was archived by the owner on Apr 2, 2018. It is now read-only.

Segmentation Fault when running optimzied #39

Closed
joe-hauns opened this issue Mar 13, 2018 · 7 comments
Closed

Segmentation Fault when running optimzied #39

joe-hauns opened this issue Mar 13, 2018 · 7 comments

Comments

@joe-hauns
Copy link

I encountered a segmentation fault after instatiating the default timer when running a binary using
cargo run --release

Here's a link to a minimal setup where i encounter this error:
https://github.com/joeschman/tokio-timer-segfault

While debugging I found out that optimization error can be avoided when inserting a print-statement after line 248 in the file tokio-timer/src/wheel.rs

    /// Returns the instant in time that corresponds to the next timeout
    /// scheduled in this wheel.
    pub fn next_timeout(&self) -> Option<Instant> {
        // TODO: can this be optimized to not look at the whole array?
        let mut min = None;
        for a in self.wheel.iter().filter_map(|s| s.next_timeout.as_ref()) {
            if let Some(b) = min {
                if b < a {
                    print!("");  // FIXME: optimization bug here
                    continue
                }
            }
            min = Some(a);
        }

        min.map(|t| *t)
    }

I'm not sure if that helps but I am running macOS 10.13.3.

I hope this bug report helps to fix the bug.

@carllerche
Copy link
Member

Do you think this is a bug in tokio-timer or a bug in Rust codegen?

The only unsafe code is in the mpmc file which I copied from the Rust source and is based on the 1024cores design, which is pretty established.

@joe-hauns
Copy link
Author

I basically think it s a bug of rust codegen but did neither know the right place to post the issue nor ambi entirely sure where the buge comes from since i didn t have a detailed look at the implementation of tokio-timer.
But by placing println!s i could find out that the segfault occurs somewhere within the loop.
Do you get this error as well when running the crate i posted?

@carllerche
Copy link
Member

No, I don't get the segfault. My OS is OS X 10.12.6.

Maybe report this on the Rust repo?

@joe-hauns
Copy link
Author

Which toolchain are you using?
I just found out the error only occurs when using beta-x86_64-apple-darwin or nightly-x86_64-apple-darwin but not when using stable-x86_64-apple-darwin.
I created an issue on the rust repo.

@fu5ha
Copy link

fu5ha commented Mar 16, 2018

I am also getting this on nightly-x86_64-pc-windows-msvc

@carllerche
Copy link
Member

Well, tokio-timer is in the process of being rewritten. So, that should "fix" the problem by virtue of it being new code...

@carllerche
Copy link
Member

Thanks for the report! This should (hopefully) be fixed by tokio-rs/tokio#249.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants