sumatrapdfreader / sumatrapdf

SumatraPDF reader
http://www.sumatrapdfreader.org
GNU General Public License v3.0
13.57k stars 1.72k forks source link

Changing an annotation causes a hang (not crash) #3709

Closed kerryland closed 1 year ago

kerryland commented 1 year ago

This one I couldn't easily replicate, so there must be a little more to it than the steps above

kjk commented 1 year ago

So far couldn't reproduce. If you're in the debugger and it happens, could you break (Ctrl + Alt + Break or pause icon in Visual Studio toolbar) and copy the callstack?

kerryland commented 1 year ago

I can't reproduce it either

kerryland commented 1 year ago

@kjk ... but it did just happen again. This time in the middle of typing an annotation comment. I will run in debugger from now on and hope I can catch it.

kerryland commented 1 year ago

Oh MAN I am getting good a this (he says, modestly).

I believe bug is related to drawing the tooltip over the active annotation, while you are typing the comment (and therefore updating the text that will appear in the tooltip).

To reproduce it do something like this:

This has happened to me twice "organically", both times when I thought I had accidentally knocked my mouse while typing.

I want a prize!

    [External Code] 
>   [Inline Frame] SumatraPDF.exe!ScopedCritSec::{ctor}(_RTL_CRITICAL_SECTION *) Line 8 C++
    SumatraPDF.exe!MarkNotificationAsModified(EngineMupdf * e, Annotation * annot, AnnotationChange change) Line 3637   C++
    SumatraPDF.exe!SetContents(Annotation * annot, const char * sv) Line 342    C++
    SumatraPDF.exe!ContentsChanged(EditAnnotationsWindow * ew) Line 926 C++
    SumatraPDF.exe!CreateMainLayout::__l9::<lambda_1>::operator()() Line 1039   C++
    [External Code] 
    SumatraPDF.exe!Edit::OnCommand(unsigned __int64 wparam, __int64 lparam) Line 1780   C++
    SumatraPDF.exe!Wnd::WndProcDefault(HWND__ * hwnd, unsigned int msg, unsigned __int64 wparam, __int64 lparam) Line 726   C++
    SumatraPDF.exe!Wnd::WndProc(HWND__ * hwnd, unsigned int msg, unsigned __int64 wparam, __int64 lparam) Line 341  C++
    SumatraPDF.exe!StaticWindowProc(HWND__ * hwnd, unsigned int msg, unsigned __int64 wparam, __int64 lparam) Line 254  C++
    [External Code] 
    SumatraPDF.exe!Wnd::FinalWindowProc(unsigned int msg, unsigned __int64 wparam, __int64 lparam) Line 909 C++
    SumatraPDF.exe!Wnd::WndProcDefault(HWND__ * hwnd, unsigned int msg, unsigned __int64 wparam, __int64 lparam) Line 905   C++
    SumatraPDF.exe!Edit::WndProc(HWND__ * hwnd, unsigned int msg, unsigned __int64 wp, __int64 lp) Line 1733    C++
    SumatraPDF.exe!StaticWindowProc(HWND__ * hwnd, unsigned int msg, unsigned __int64 wparam, __int64 lparam) Line 254  C++
    SumatraPDF.exe!StaticWindowProcSubclassed(HWND__ * hwnd, unsigned int msg, unsigned __int64 wp, __int64 lp, unsigned __int64 subclassId, unsigned __int64 data) Line 263    C++
    [External Code] 
    SumatraPDF.exe!RunMessageLoop() Line 581    C++
    SumatraPDF.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * __formal, char * __formal, int __formal) Line 1408    C++
    [External Code] 
kerryland commented 1 year ago

It happened again. This time I'm fairly sure the mouse wasn't about to produce a tooltip, but the call stack looks the same:

    [External Code] 
    [Inline Frame] SumatraPDF.exe!ScopedCritSec::{ctor}(_RTL_CRITICAL_SECTION *) Line 8 C++
    SumatraPDF.exe!MarkNotificationAsModified(EngineMupdf * e, Annotation * annot, AnnotationChange change) Line 3637   C++
    SumatraPDF.exe!SetContents(Annotation * annot, const char * sv) Line 342    C++
    SumatraPDF.exe!ContentsChanged(EditAnnotationsWindow * ew) Line 926 C++
    SumatraPDF.exe!CreateMainLayout::__l9::<lambda_1>::operator()() Line 1039   C++
    [External Code] 
    SumatraPDF.exe!Edit::OnCommand(unsigned __int64 wparam, __int64 lparam) Line 1780   C++
    SumatraPDF.exe!Wnd::WndProcDefault(HWND__ * hwnd, unsigned int msg, unsigned __int64 wparam, __int64 lparam) Line 726   C++
    SumatraPDF.exe!Wnd::WndProc(HWND__ * hwnd, unsigned int msg, unsigned __int64 wparam, __int64 lparam) Line 341  C++
    SumatraPDF.exe!StaticWindowProc(HWND__ * hwnd, unsigned int msg, unsigned __int64 wparam, __int64 lparam) Line 254  C++
    [External Code] 
    SumatraPDF.exe!Wnd::FinalWindowProc(unsigned int msg, unsigned __int64 wparam, __int64 lparam) Line 909 C++
    SumatraPDF.exe!Wnd::WndProcDefault(HWND__ * hwnd, unsigned int msg, unsigned __int64 wparam, __int64 lparam) Line 905   C++
    SumatraPDF.exe!Edit::WndProc(HWND__ * hwnd, unsigned int msg, unsigned __int64 wp, __int64 lp) Line 1733    C++
    SumatraPDF.exe!StaticWindowProc(HWND__ * hwnd, unsigned int msg, unsigned __int64 wparam, __int64 lparam) Line 254  C++
    SumatraPDF.exe!StaticWindowProcSubclassed(HWND__ * hwnd, unsigned int msg, unsigned __int64 wp, __int64 lp, unsigned __int64 subclassId, unsigned __int64 data) Line 263    C++
    [External Code] 
    SumatraPDF.exe!RunMessageLoop() Line 581    C++
>   SumatraPDF.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * __formal, char * __formal, int __formal) Line 1408    C++
    [External Code] 
kjk commented 1 year ago

Thanks for the repro, that's definitely a deadlock. The main thread is waiting for critical section that some other thread is holding.

kjk commented 1 year ago

Should be fixed.

In case you can still repro the deadlock, please post callstack for other threads as well. That helps investigating deadlocks because it shows which other thread is holding the lock that the deadlocking thread is waiting on.