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

Can't capture Rust process #78

Closed
Jasper-Bekkers opened this issue Sep 16, 2022 · 9 comments
Closed

Can't capture Rust process #78

Jasper-Bekkers opened this issue Sep 16, 2022 · 9 comments

Comments

@Jasper-Bekkers
Copy link

It looks like something is slightly off when capturing Rust applications. I'm trying to capture my application, but it instantly terminates (I can vaguely make out a copyright notice when it does).

However, invoking the application manually through a command like C:\Users\Jasper\Downloads\mtuner64\MTuner\MTunerInject64.exe #23#C:/Users/Jasper/rust-test/target/debug/rust-test.exe#23# #23##23# #23##23# does seem to produce somewhat correct output. It does look like the injector tool returns back to the terminal but the application keeps living, leading to output like this;

C:\Users\Jasper>C:\Users\Jasper\Downloads\mtuner64\MTuner\MTunerInject64.exe #23#C:/Users/Jasper/rust-test/target/debug/rust-test.exe#23# #23##23# #23##23#
16:01:30;192;0mINFO  Copyright (c) 2019 Milos Tosic. All rights reserved.

Hi

C:\Users\Jasper>Hi
Hi
Hi
Hi
Hi

Attached is a Rust application that does the following;

fn main() {
    let mut k = vec![];

    loop {
        k.push(12);
        println!("Hi");
        std::thread::sleep(std::time::Duration::from_secs(1));
    }
}

(can be re-created with cargo new rust-test and then pasting the code above in main.rs, then running cargo build)

One clue / red herring might be that rust applications typically are compiled with /SUBSYSTEM:Console, though I'm not sure if it's related or not.

rust-test.zip

@Jasper-Bekkers
Copy link
Author

One clue / red herring might be that rust applications typically are compiled with /SUBSYSTEM:Console, though I'm not sure if it's related or not.

Turns out that's a red-herring. It looks like the application does live for a short while, and then just gets terminated.

@Jasper-Bekkers
Copy link
Author

I've also attached the resulting capture that's being made, something is off here, because from the loop above you'd expect the application to loop indefinitely and never terminate, but for some reason a capture is being made (even showing traces inside print / vec) but the app just lives way too short.

rust-test.2022.9.16.16.57..371.zip

@milostosic
Copy link
Collaborator

First thing that comes to mind is that injected DLL crashes bringing down the whole process. Regarding the text output from the first post, it seems this was done with older MTuner and there is likely a bug that could be causing missing text which was fixed recently. Might be worth trying with v4.5.0

@Jasper-Bekkers
Copy link
Author

I can debug this a bit if you give me some pointers how to set it up under visual studio

@Jasper-Bekkers
Copy link
Author

First thing that comes to mind is that injected DLL crashes bringing down the whole process. Regarding the text output from the first post, it seems this was done with older MTuner and there is likely a bug that could be causing missing text which was fixed recently. Might be worth trying with v4.5.0

I just double checked two things;

  • A fresh download of v4.5.0, this didn't produce any noticeable difference
  • Checked my old download of MTuner and this indicates it's version v4.5.0 in the main window

@milostosic
Copy link
Collaborator

I just tried this and it's working for me fine. 'Hi' is printed indefinitely and once I close the console window (kill the process) the capture file is stored as expected. I built the test locally, did not use your executable.

@Jasper-Bekkers
Copy link
Author

I just tried this and it's working for me fine. 'Hi' is printed indefinitely and once I close the console window (kill the process) the capture file is stored as expected. I built the test locally, did not use your executable.

Yes that's expected (see first description of the issue), however, when running the rust app normally it doesn't pick it up and won't capture.

@milostosic
Copy link
Collaborator

What do you mean by "when running the rust app normally it doesn't pick it up and won't capture"? I could also drag and drop your example to MTuner window and it's working fine.

@Jasper-Bekkers
Copy link
Author

Exactly that part (either drag & drop, or through the advanced settings) isn't working for me it seems. I think the rust app panics and terminates early for some reason, but I can't read stderr/ stdout so I have no way of figuring out what's going on.

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