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

Arguments with spaces passed to the program incorrectly #17

Open
tko opened this issue Mar 22, 2020 · 5 comments
Open

Arguments with spaces passed to the program incorrectly #17

tko opened this issue Mar 22, 2020 · 5 comments

Comments

@tko
Copy link

tko commented Mar 22, 2020

Given the following code

fn main() {
    let arg = std::env::args().nth(1).unwrap();
    if arg.contains(" ") {
        loop{}
    }
}

profiling it with cargo instruments "space here" completes in few seconds as the single argument appears to get split and passed as two arguments "space" and "here" separately.

@cmyr
Copy link
Owner

cmyr commented Mar 22, 2020

are you trying to pass arguments through to the target? I think the syntax is cargo instruments -- your args, does that work?

@tko
Copy link
Author

tko commented Mar 22, 2020

Yes. And no, -- makes no difference.

@cmyr
Copy link
Owner

cmyr commented Mar 22, 2020

Okay I'm probably not going to have time to investigate this for a while, but if you're motivated I would certainly accept a patch.

@tko
Copy link
Author

tko commented Mar 23, 2020

After some investigation I see cargo-instruments is simply passing the arguments to instruments and it's the latter that is misbehaving as can be reproduced with

instruments -t "Time Profiler" ./target/debug/main "space here"

Not sure there's anything one can do other than complaining to Apple.

@cmyr
Copy link
Owner

cmyr commented Mar 24, 2020

yea you can file a radar but I wouldn't expect anything to come of it.

Best case scenario is likely that they end up using more Rust and end up using this utility and someone internal hits this bug 😆.

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

2 participants