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

Crashes while unhooking #139

Open
OneXDeveloper opened this issue Nov 18, 2023 · 1 comment
Open

Crashes while unhooking #139

OneXDeveloper opened this issue Nov 18, 2023 · 1 comment

Comments

@OneXDeveloper
Copy link

Hi, me again! Been awhile!

I'm still facing crashes frequently while ejecting for DX12 game D2R. I also sometimes get crashes while injecting. I think there might still be a sync issue somewhere. Could you help me debug? What info can I give you that would help?

Here's the last log I get when it crashes during eject.

DEBUG hudhook::hooks::dx12: WndProc called before hook was set

If it would be easier to chat over discord, I'd be down to help track these down. They're driving me crazy :P

@veeenu
Copy link
Owner

veeenu commented Nov 18, 2023

Hi! Thank you for reporting this!

Unfortunately it's not a great moment for me, between commitments and other personal issues, so I've paused work on hudhook for a bit. I'll still review pull requests though, so if you get to this before I have a chance to, feel free to open one!

The culprit is most likely around here:

hudhook/src/hooks/dx12.rs

Lines 782 to 809 in bebcddc

unsafe fn unhook(&mut self) {
trace!("Disabling hooks...");
CQECL_RUNNING.wait();
PRESENT_RUNNING.wait();
RBUF_RUNNING.wait();
trace!("Cleaning up renderer...");
if let Some(renderer) = IMGUI_RENDERER.take() {
let mut renderer = renderer.lock();
// XXX
// This is a hack for solving this concurrency issue:
// https://github.com/veeenu/hudhook/issues/34
// We should investigate deeper into this and find a way of synchronizing with
// the moment the actual resources involved in the rendering are
// dropped. Using a condvar like above does not work, and still
// leads clients to crash.
//
// The 34ms value was chosen because it's a bit more than 1 frame @ 30fps.
thread::sleep(Duration::from_millis(34));
renderer.cleanup(None);
}
drop(IMGUI_RENDER_LOOP.take());
COMMAND_QUEUE_GUARD.take();
DXGI_DEBUG_ENABLED.store(false, Ordering::SeqCst);
}

The synchronization is already a hack, and a potential solution is included in the comment, but I (personally) need a better understanding of the DX12 pipeline to debug that. Attaching a debugger to inspect the crash should provide some insight.

This was referenced Feb 24, 2024
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