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

executable doesn't ever close. #29679

Closed
pmwhite opened this issue Nov 7, 2015 · 9 comments
Closed

executable doesn't ever close. #29679

pmwhite opened this issue Nov 7, 2015 · 9 comments

Comments

@pmwhite
Copy link

pmwhite commented Nov 7, 2015

use std::collections::BTreeMap;

enum Object {
    Str(String),
    Int(i32),
    Float(f32),
    Vector(Vec<Object>),
    //Prim(fn(State) -> State)
}

//struct State<'a> {
    //named: &'a mut BTreeMap<String, Object<'a>>,
    //stack: Vec<Object<'a>>
//}

fn printObj(obj: &Object) {
    println!("starting object...");
    match obj {
        &Object::Str(ref s) => println!("string: {}", s),
        &Object::Int(ref i) => println!("int: {}", i),
        &Object::Float(ref f) => println!("float: {}", f),
        &Object::Vector(ref v) => {
            println!("Vector: ");
            for item in v {
                printObj(item);
            }
        },
        //Object::Prim(f) => println!("primitive function")
    }
    println!("ending object...");
}
//fn print(state: &State<'a>) {
    //for (key, value) in state.named.iter() {
        //println!("{}", key);
        //printObj(value);
        //println!("");
    //}
//}

fn main() {
    println!("Hello, world!");
    let obj = Object::Str("this is a test".to_string());
    printObj(&obj);
}

I wrote the code above to get more familiar with rust. This is the exact code; I didn't even take out the commented parts.

I ran cargo build, which gave me a snake case warning and a few unused code warnings. I was so pleased at actually succeeding in building it that I didn't care about the warnings.

I next ran cargo run. Confusingly, it hung. I ctrl-c'd the process and continued on my way. I then tried again. Same thing happened. I decided to rebuild, so I changed the file by adding a blank line; I then cargo build'd again, and I got back Unknown error and something to the effect of use the verbose flag to find out more.
When I used the verbose flag, I got Access is denied (OS error 5)
After a bit of searching, I discovered in the task manager that the process was still running. Logically, I attempted to kill the process; I got back a dialog box saying Access is denied.

I tried signing out and signing back in, to no avail. I was googling around and it seemed that the only solution was to shut down and restart my computer. This succeeded.
My googling leads me to believe that I was unable to close the process because it was in kernel mode or something driver related.
I found this: http://superuser.com/questions/585073/how-to-overcome-access-denied-when-killing-process-in-windows; it seems to be related, but it didn't fix anything.

After I restarted, I ran the program again. It hung again, but this time I closed the cmd prompt instead of ctrl-c'ing the process. The process did not hang around forever this time.

I'm not really sure if this is an issue with rust, and perhaps I should have just SO'ed the code and come here second, but here it is.

I'm using windows 10 and Rust 1.3; anything else you need to know, just ask.

@steveklabnik
Copy link
Member

Hmm, it works just fine in the playpen: http://is.gd/SHT79w

do you maybe have an antivirus that might be interfering or something?

@pmwhite
Copy link
Author

pmwhite commented Nov 7, 2015

@steveklabnik I know, I just tried it on the playground.

It might be an antivirus; I don't know how to check if its that, so either give me time to google it, or tell me how.

@pmwhite
Copy link
Author

pmwhite commented Nov 7, 2015

It doesn't seem like it's antivirus. Just now I tried to rebuild the project.
Once again I got an unknown error. I tried to delete the executable and got the action could not be completed because the file is being used in System or something like that.
I checked the task manager, but I didn't see the program running.
I signed out and in again. When I got back, I checked the task manager, and there the process was - unable to be stopped either.

Note, the process never shows up on the processes tab of the task manager; it's in the details tab.

The process is at 0 CPU and 52 or 56 K memory constantly.

@pmwhite
Copy link
Author

pmwhite commented Nov 7, 2015

I copied the .toml file and the src folder and rebuilt it. The process hung again, but it didn't get stuck.

It must be rust's fault for hanging because the project is as clean as can be. The process hanging around could possibly be my fault if it depends on how I close the process.

@pmwhite
Copy link
Author

pmwhite commented Nov 8, 2015

I've been experimenting some more, and my problem has nothing to do with the code.
I did a whole new cargo new, and that didn't work. I upgraded to rust 1.4 and that didn't help either.

I don't think rust has anything to do with it, so this issue can probably be closed. It's my problem now.

@pmwhite pmwhite closed this as completed Nov 8, 2015
@RexMorgan
Copy link

I'm seeing this same error on 1.8.0-nightly (7fce5037a 2016-02-07) 32bit GNU ABI.

I'm not sure if this is just your problem @pmwhite, I think it might be something related to rust.

This is on a fairly recent (within the past 2-3 weeks) install of windows 10.

Thanks for the pointer on killing the process, that worked for me and I didn't get an Access Denied error.

For me, everything works fine the first run, then I go make some changes and attempt to do another cargo run --verbose and get the error Access is denied. (os error 5). When I kill the process (the .exe that was running with the working cargo run), I can then do a cargo run and it works successfully.

I am using ctrl+c to exit the process, however closing the terminal window doesn't seem to fix the issue.

I just wanted to add that since the process is still running, after I ctrl+c my iron test project that I'm playing with, I can still access the site and it still prints to the console that I closed it from.
image

@jonas-schievink
Copy link
Contributor

@RexMorgan This should have been fixed by rust-lang/cargo#2370, I believe

@alexcrichton
Copy link
Member

Ah yes @RexMorgan it looks like that problem is addressed by the PR @jonas-schievink linked to, specifically it's entirely Cargo related rather than rustc-related.

@RexMorgan
Copy link

Awesome, thanks, I missed that cargo issue :)

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