cargo-instruments icon indicating copy to clipboard operation
cargo-instruments copied to clipboard

Arguments with spaces passed to the program incorrectly

Open tko opened this issue 5 years ago • 5 comments

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.

tko avatar Mar 22 '20 10:03 tko

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

cmyr avatar Mar 22 '20 14:03 cmyr

Yes. And no, -- makes no difference.

tko avatar Mar 22 '20 14:03 tko

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.

cmyr avatar Mar 22 '20 16:03 cmyr

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.

tko avatar Mar 23 '20 08:03 tko

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 😆.

cmyr avatar Mar 24 '20 15:03 cmyr