Skip to content

run-pass/issue-10626.rs goes nuts #10790

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

Closed
vmx opened this issue Dec 4, 2013 · 12 comments
Closed

run-pass/issue-10626.rs goes nuts #10790

vmx opened this issue Dec 4, 2013 · 12 comments
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc

Comments

@vmx
Copy link
Contributor

vmx commented Dec 4, 2013

On my machine the run-pass/issue-10626.rs goes nuts. It takes all my memory (8GB RAM, with a few things running, but not really much) and then started to swap (another 8GB then my disk was full).

When I ps aux I can see more and more processes called x86_64-unknown-linux-gnu/test/run-pass/issue-10626.stage2-x86_64-unknown-linux-gnu spinning up. The highest number I saw before it got very unresponsive was around 2800 processes.

All this was a make check on a recent master 69186efc199d48afca9427e448363212b0a59454. I had one of my own commits on top of that, but I really don't think that commit can cause this issue (I currently rerun with a clean master though).

@alexcrichton
Copy link
Member

Hm, this would happen if the child doesn't see that it's a child (args isn't passed correctly maybe?).

Out of curiosity, does this modification to the program pass for you?

use std::os;                                           
use std::io::process;                                  

fn main () {                                           
    let args = os::args();                             
    if args.len() > 1 && args[1] == ~"child" {         
        for _ in range(0, 1000) {                      
            error!("hello?");                          
        }                                              
        for _ in range(0, 1000) {                      
            println!("hello?");                        
        }                                              
    }                                                  

    let args = [~"child"];                            
    let config = process::ProcessConfig {              
        program : args[0].as_slice(),                  
        args : args,                             
        env : None,                                    
        cwd : None,                                    
        io : []                                        
    };                                                 

    let mut p = process::Process::new(config).unwrap();
    println!("{}", p.wait());                          
}                                                      

@vmx
Copy link
Contributor Author

vmx commented Dec 4, 2013

I get:

task '<main>' failed at 'Unhandled condition: io_error: io::IoError{kind: OtherIoError, desc: "no such file or directory", detail: None}', /home/vmx/src/rust/rust/src/libstd/condition.rs:131

@vmx
Copy link
Contributor Author

vmx commented Dec 4, 2013

When I rename the let args = [~"child"]; to args2 it runs, without error, but has the same problem as the original version.

@vmx
Copy link
Contributor Author

vmx commented Dec 4, 2013

I shouldn't code when I'm tired. When I rename the let args = [~"child"]; to args2 and replace only the args in the ProcessConfig but leave the program with the original args, then it runs but has the original problem. When I also replace the program with args2, I get the runtime error as mentioned above.

@alexcrichton
Copy link
Member

Oh sorry I didn't realize that things were getting shadowed. Can you print the contents of os::args() to see what's getting passed to the children?

@vmx
Copy link
Contributor Author

vmx commented Dec 4, 2013

When I add a println!("args: {:?}", os::args()); at the beginning of fn main() the output is:

$ /tmp/vmx-issue-10626 
args: ~[~"/tmp/vmx-issue-10626"]

@alexcrichton
Copy link
Member

I'm more interested in what the children are printing, you'll probably have to set it up such that they inherit the stdio/stderr file descriptors.

@vmx
Copy link
Contributor Author

vmx commented Dec 4, 2013

BTW: I can confirm that the issue is also there on a clean master (commit 693ec73).

@vmx
Copy link
Contributor Author

vmx commented Dec 4, 2013

After some IRC discussion the conclusion was that it needs more investigation. Here's the code to see what the children print out. I've commented the original println! and error! out to see a bit clearer what the arguments of the children are.

use std::os;
use std::io::process;
use std::io::process::InheritFd;

fn main () {
    println!("args: {:?}", os::args());

    let args = os::args();
    if args.len() > 1 && args[1] == ~"child" {
        //for _ in range(0, 1000) {
        //    error!("hello?");
        //}
        //for _ in range(0, 1000) {
        //    println!("hello?");
        //}
    }

    let io = [InheritFd(0), InheritFd(1), InheritFd(2)];
    let config = process::ProcessConfig {
        program : args[0].as_slice(),
        args : [~"child"],
        env : None,
        cwd : None,
        io : io
    };

    let mut p = process::Process::new(config).unwrap();
    println!("{}", p.wait());
}

The output for every child is then:

args: ~[~"./vmx-issue-10626", ~"child"]

I'm on Debian testing 64-bit.

@dwrensha
Copy link
Contributor

dwrensha commented Dec 4, 2013

Looks to me like the test just needs to put the rest of its body in an else branch, like this:

use std::os;
use std::io::process;

fn main () {
    let args = os::args();
    if args.len() > 1 && args[1] == ~"child" {
        for _ in range(0, 1000) {
            error!("hello?");
        }
        for _ in range(0, 1000) {
            println!("hello?");
        }
    } else {
        let config = process::ProcessConfig {
            program : args[0].as_slice(),
            args : [~"child"],
            env : None,
            cwd : None,
            io : []
        };

        let mut p = process::Process::new(config).unwrap();
        println!("{}", p.wait());
    }
}

@alexcrichton
Copy link
Member

I'm... not sure how I didn't see that before. I'm also not entirely sure how this is passing at all today.

Regardless, thanks @dwrensha!

alexcrichton added a commit to alexcrichton/rust that referenced this issue Dec 4, 2013
Note entirely sure how this is passing at all today, but regardless this fixes
the problems seen in rust-lang#10790
@vmx
Copy link
Contributor Author

vmx commented Dec 4, 2013

I can confirm that #10794 fixes this issue.

@bors bors closed this as completed in 9169579 Dec 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants