greatscottgadgets / packetry

A fast, intuitive USB 2.0 protocol analysis application for use with Cynthion.
BSD 3-Clause "New" or "Revised" License
121 stars 24 forks source link

Packetry crashes when resizing #178

Closed x0rloser closed 4 hours ago

x0rloser commented 3 weeks ago

Like the title says I can crash packetry by just resizing the main window. This happens without opening any log or having any cynthion hw connected to my machine. There is nothing printed to console if I start it from the console, and no msgboxes or anything are displayed. The program just quits out immediately.

Done using packetry v0.2.1 release from git for Windows. I am using Windows 11 x64 with all latest windows updates. I do have multiple monitors, but it crashes even when I keep the bounds of the window within my main (middle) monitor.

Replication steps: 1) start packetry (either from windows start menu or from command line) 2) position mouse cursor on the bottom right corner until you see the "resize" mouse cursor show up. 3) click and hold the resize cursor the move the mouse anticlockwise circles like you are drawing a clockface, starting at the 12 at the top and moving thru the 9, 6, 3, and back to 12 again. 4) The program crashes and disappears for me everytime after 1 or 2 anticlockwise circles.

x0rloser commented 3 weeks ago

I tried this on the Linux build running on Ubuntu v22.04 and I cannot get it to crash.

martinling commented 3 weeks ago

If you run packetry-cli from the console, you should get some debug output, and also a backtrace if you run set RUST_BACKTRACE=1 beforehand. My guess is that it will be some internal crash in GTK's Windows backend.

x0rloser commented 3 weeks ago

I did try with packetry-cli from console already and got no debug output. I also tried just now after setting that env variable and also got no output. Here are the commands i tried just in case I am doing something wrong:

C:\Program Files\Packetry\bin>set RUST_BACKTRACE=1
C:\Program Files\Packetry\bin>echo %RUST_BACKTRACE%
1
C:\Program Files\Packetry\bin>packetry-cli
C:\Program Files\Packetry\bin>

It returned to the comand prompt when the program crashed.

mossmann commented 1 week ago

@x0rloser Was this from the binary installer or compiled from source? Have you tried release 0.2.2?

I've been unable to reproduce the problem with 0.2.1 or 0.2.2 from the binary installer.

martinling commented 5 days ago

I'm also unable to reproduce this with the 0.2.2 installer.

x0rloser commented 3 days ago

I just tried with the v0.2.2 installer for windows from github releases page, and it still crashes in the same way.

Previously I had used the v0.2.1 installer for windows from the github releases page.

martinling commented 3 days ago

I haven't been able to try this on Windows with multiple monitors yet.

Are you able to reproduce this if you disconnect all but one monitor?

martinling commented 3 days ago

Also: are you able to reproduce this with any of the GTK example programs? I suspect that this is going to turn out to be a GTK bug that's specific to the Windows backend on multi-monitor systems.

x0rloser commented 2 days ago

I disabled all my monitors except one (via display settings -> disconnect this monitor), and set the remaining monitor to the standard "landscape" mode. I tested again and I get the same crash when resizing.

Are the GTK exmaple programs available anywhere prebuilt for windows? I don't have the time just now get a working gtk dev env sorted.

martinling commented 2 days ago

The gvsbuild project has binary releases of the full GTK stack for Windows, but I've just checked and they don't include the example programs unfortunately.

x0rloser commented 2 days ago

Ok I found some time to setup a dev environment. I get the same crash running the most basic "hello world" apps. I built helloworld apps in gtk-rs and plain old gtk (ie a C code app).

So it seems the problem is most likely not in packetry, or the rust bindings, but in GTK itself. (Or perhaps in the gvsbuild versions of GTK)

I tried using prebuilt versions of GTK from the release GTK4_Gvsbuild_2024.9.0_x64.zip, as well as building the source myself using the MSVC way and they both fail.

martinling commented 2 days ago

Thanks for taking the time to investigate!

Our release builds are built with GTK from vcpkg, built using MSVC, so I think the symptoms point to an underlying GTK bug.

x0rloser commented 2 days ago

I tried debugging the "access violation exception: 0xC0000005" in visual studio for the simple C app. The last non-garbage looking code was in nvoglv64.dll, which is an nvidia driver. There were some calls above this, but they looked like they might have been due to memory corruption, as they looked bogus.

"nvoglv64.dll" is nvidia video driver related, so I tried updating to the latest drivers but that did not fix the crash. So perhaps it only occurs on nvidia hw - I have a 3080.

I also narrowed down the bug a little more. It occurs when I resize the main window in these ways:

martinling commented 2 days ago

I think the best next step is to write up your findings in an issue at https://gitlab.gnome.org/GNOME/gtk/-/issues.

x0rloser commented 5 hours ago

thanks for the link - i've reported the issue there, and while it does seem somewhat nvidia driver related, im still hoping it will get fixed so i don't lose whatever i am doing in packetry due to reszing the window xD

x0rloser commented 4 hours ago

I reported this issue to the gnome/gtk gitlab project. It seems the problem is due to "NahimicOSD" dll, and is a known problem.

For more info see: https://gitlab.gnome.org/GNOME/gtk/-/issues/7003

The fix that worked for me was:

Open up services.msc as Admin, and scroll down to 'Nahimic service' ... right click 'Stop', and then right click 'Properties'. While in the 'General' tab, make sure 'Startup type' says 'Disabled'. Then in the 'Recovery' tab, make sure the 'recovery failures' are all set to 'Take No Action' . And then click OK when you are all set. Click on the pictures below to see the whole image. Good luck !

After doing this it packetry no longer crashes for me during resizing.

For the record, I didn't have to reboot or anything after doing this.

martinling commented 4 hours ago

Glad you were able to track that down!