RudjiGames / MTuner

MTuner is a C/C++ memory profiler and memory leak finder for Windows, PlayStation 4 and 3, Android and other platforms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't capture Rust process

Jasper-Bekkers opened this issue · comments

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

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.

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

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 can debug this a bit if you give me some pointers how to set it up under visual studio

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

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.

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.

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.

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.