Beep6581 / RawTherapee

A powerful cross-platform raw photo processing program
https://rawtherapee.com
GNU General Public License v3.0
2.81k stars 318 forks source link

Crash when in save file dialog and searching the files by typing #5213

Closed hafilax closed 4 years ago

hafilax commented 5 years ago

In the "save image" dialog, if one of the files in the folder is selected and I start typing the system crashes. It looks like it is attempting to search the folder. If I make sure to click on the text entry field it does not crash.

Late 2010 Macbook Mac OSX 10.13.6

Version: 5.5
Branch: 5.5
Commit: d9ac23555
Commit date: 2018-12-17
Compiler: clang 10.0.0.10001145
Processor: generic x86
System: Apple
Bit depth: 64 bits
Gtkmm: V3.22.3
Lensfun: V0.3.95.0
Build type: release
Build flags: -std=c++11 -std=c++11 -mtune=generic -Werror=unused-label -mmacosx-version-min=10.9 -flto -Wall -Wuninitialized -Wno-deprecated-declarations -Wno-unused-result -Xpreprocessor -fopenmp /opt/local/lib/libiomp5.dylib -I/opt/local/include -Werror=unknown-pragmas -O3 -DNDEBUG -ftree-vectorize
Link flags:  -mtune=generic -headerpad_max_install_names -flto
OpenMP support: ON
MMAP support: ON
Beep6581 commented 5 years ago

@hafilax please try the latest dev development build from https://discuss.pixls.us/t/download-rawtherapee-development-builds/2924 If you can still reproduce it, let us know which version of the development build you used, and ideally provide a stack backtrace as described here: http://rawpedia.rawtherapee.com/How_to_write_useful_bug_reports#When_RawTherapee_crashes_-_An_introduction_to_stack_backtraces

okoncevoy commented 5 years ago

I have reproduced this issue building yesterday dev.

Version: 5.5-166-gd89364fcc
Branch: dev
Commit: d89364fcc
Commit date: 2019-03-10
Compiler: clang-mp-7 7.0.1
Processor: i386
System: Apple
Bit depth: 64 bits
Gtkmm: V3.22.3
Lensfun: V0.3.2.0
Build type: Debug
Build flags:  -std=c++11  -Werror=unused-label -mmacosx-version-min=10.9 -Wall -Wuninitialized -Wno-deprecated-declarations -Wno-unused-result -fopenmp=libomp -Werror=unknown-pragmas -g -ftree-vectorize
Link flags:   -headerpad_max_install_names
OpenMP support: ON
MMAP support: ON

I also have backtrace, but I've got it using lldb.

thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    frame #0: 0x0000000101de6564 libgio-2.0.0.dylib`g_file_hash + 26
    frame #1: 0x0000000102024f36 libglib-2.0.0.dylib`g_hash_table_contains + 60
    frame #2: 0x0000000102655845 libgtk-3.0.dylib`hits_added + 44
    frame #3: 0x0000000101fc7b31 libgobject-2.0.0.dylib`g_closure_invoke + 200
    frame #4: 0x0000000101fdae5f libgobject-2.0.0.dylib`signal_emit_unlocked_R + 1557
    frame #5: 0x0000000101fdba3c libgobject-2.0.0.dylib`g_signal_emit_valist + 1828
    frame #6: 0x0000000101fdc108 libgobject-2.0.0.dylib`g_signal_emit + 120
    frame #7: 0x00000001028c8015 libgtk-3.0.dylib`-[ResultReceiver submitHits:] + 248
    frame #8: 0x00007fff35eb3362 CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    frame #9: 0x00007fff35eb32dc CoreFoundation`___CFXRegistrationPost_block_invoke + 63
    frame #10: 0x00007fff35eb31fd CoreFoundation`_CFXRegistrationPost + 398
    frame #11: 0x00007fff35ebb531 CoreFoundation`___CFXNotificationPost_block_invoke + 87
    frame #12: 0x00007fff35e23384 CoreFoundation`-[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1804
    frame #13: 0x00007fff35e22629 CoreFoundation`_CFXNotificationPost + 854
    frame #14: 0x00007fff381c8a7b Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 66
    frame #15: 0x00007fff35eb3362 CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    frame #16: 0x00007fff35eb32dc CoreFoundation`___CFXRegistrationPost_block_invoke + 63
    frame #17: 0x00007fff35eb31fd CoreFoundation`_CFXRegistrationPost + 398
    frame #18: 0x00007fff35ebb531 CoreFoundation`___CFXNotificationPost_block_invoke + 87
    frame #19: 0x00007fff35e23384 CoreFoundation`-[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1804
    frame #20: 0x00007fff35e22629 CoreFoundation`_CFXNotificationPost + 854
    frame #21: 0x00007fff35e221df CoreFoundation`CFNotificationCenterPostNotificationWithOptions + 121
    frame #22: 0x00007fff376a647c Metadata`_postQueryNotification + 214
    frame #23: 0x00007fff37679a79 Metadata`___pushNotification_block_invoke + 60
    frame #24: 0x00007fff35e8ca6c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    frame #25: 0x00007fff35e4fde8 CoreFoundation`__CFRunLoopDoBlocks + 393
    frame #26: 0x00007fff35e4fb46 CoreFoundation`__CFRunLoopRun + 2845
    frame #27: 0x00007fff35e4edd6 CoreFoundation`CFRunLoopRunSpecific + 467
    frame #28: 0x00007fff350d8ab5 HIToolbox`RunCurrentEventLoopInMode + 293
    frame #29: 0x00007fff350d87eb HIToolbox`ReceiveNextEventCommon + 618
    frame #30: 0x00007fff350d8568 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 64
    frame #31: 0x00007fff33393363 AppKit`_DPSNextEvent + 997
    frame #32: 0x00007fff33392102 AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1362
    frame #33: 0x0000000102c7965a libgdk-3.0.dylib`poll_func + 172
    frame #34: 0x00000001020339dd libglib-2.0.0.dylib`g_main_context_iterate + 340
    frame #35: 0x0000000102033c69 libglib-2.0.0.dylib`g_main_loop_run + 191
    frame #36: 0x00000001026e4d35 libgtk-3.0.dylib`gtk_dialog_run + 334
    frame #37: 0x000000010021f69c rawtherapee`EditorPanel::saveAsPressed(this=0x000000010b33a3f0) at editorpanel.cc:1866
    frame #38: 0x0000000100234f98 rawtherapee`sigc::bound_mem_functor0<void, EditorPanel>::operator(this=0x000000010db0b028)() const at mem_fun.h:1991
    frame #39: 0x0000000100234f19 rawtherapee`sigc::adaptor_functor<sigc::bound_mem_functor0<void, EditorPanel> >::operator(this=0x000000010db0b020)() const at adaptor_trait.h:256
    frame #40: 0x0000000100234ef1 rawtherapee`sigc::internal::slot_call0<sigc::bound_mem_functor0<void, EditorPanel>, void>::call_it(rep=0x000000010db0aff0) at slot.h:136
    frame #41: 0x0000000101f5c2c0 libglibmm-2.4.1.dylib`Glib::SignalProxyNormal::slot0_void_callback(_GObject*, void*) + 52
    frame #42: 0x0000000101fc7b31 libgobject-2.0.0.dylib`g_closure_invoke + 200
    frame #43: 0x0000000101fdb0a5 libgobject-2.0.0.dylib`signal_emit_unlocked_R + 2139
    frame #44: 0x0000000101fdba3c libgobject-2.0.0.dylib`g_signal_emit_valist + 1828
    frame #45: 0x0000000101fdc108 libgobject-2.0.0.dylib`g_signal_emit + 120
    frame #46: 0x00000001026827e0 libgtk-3.0.dylib`multipress_pressed_cb + 75
    frame #47: 0x000000010349a914 libffi.6.dylib`ffi_call_unix64 + 76
    frame #48: 0x000000010349a2cd libffi.6.dylib`ffi_call + 797
    frame #49: 0x0000000101fc8e4f libgobject-2.0.0.dylib`g_cclosure_marshal_generic_va + 1267
    frame #50: 0x0000000101fc7d04 libgobject-2.0.0.dylib`_g_closure_invoke_va + 213
    frame #51: 0x0000000101fdb77f libgobject-2.0.0.dylib`g_signal_emit_valist + 1127
    frame #52: 0x0000000101fdc108 libgobject-2.0.0.dylib`g_signal_emit + 120
    frame #53: 0x000000010272960a libgtk-3.0.dylib`gtk_gesture_multi_press_begin + 359
    frame #54: 0x0000000101fcac70 libgobject-2.0.0.dylib`g_cclosure_marshal_VOID__BOXEDv + 178
    frame #55: 0x0000000101fc7d04 libgobject-2.0.0.dylib`_g_closure_invoke_va + 213
    frame #56: 0x0000000101fdb77f libgobject-2.0.0.dylib`g_signal_emit_valist + 1127
    frame #57: 0x0000000101fdc108 libgobject-2.0.0.dylib`g_signal_emit + 120
    frame #58: 0x00000001027265a4 libgtk-3.0.dylib`_gtk_gesture_check_recognized + 57
    frame #59: 0x0000000102727cdd libgtk-3.0.dylib`gtk_gesture_handle_event + 452
    frame #60: 0x000000010272ad6c libgtk-3.0.dylib`gtk_gesture_single_handle_event + 470
    frame #61: 0x00000001026fc042 libgtk-3.0.dylib`gtk_event_controller_handle_event + 107
    frame #62: 0x0000000102893338 libgtk-3.0.dylib`_gtk_widget_run_controllers + 108
    frame #63: 0x000000010276ab7b libgtk-3.0.dylib`_gtk_marshal_BOOLEAN__BOXEDv + 188
    frame #64: 0x0000000101fc7d04 libgobject-2.0.0.dylib`_g_closure_invoke_va + 213
    frame #65: 0x0000000101fdb77f libgobject-2.0.0.dylib`g_signal_emit_valist + 1127
    frame #66: 0x0000000101fdc108 libgobject-2.0.0.dylib`g_signal_emit + 120
    frame #67: 0x0000000102892eae libgtk-3.0.dylib`gtk_widget_event_internal + 254
    frame #68: 0x00000001027697f8 libgtk-3.0.dylib`propagate_event + 367
    frame #69: 0x0000000102768bc5 libgtk-3.0.dylib`gtk_main_do_event + 979
    frame #70: 0x0000000102c56869 libgdk-3.0.dylib`_gdk_event_emit + 49
    frame #71: 0x0000000102c79c96 libgdk-3.0.dylib`gdk_event_dispatch + 50
    frame #72: 0x0000000102033738 libglib-2.0.0.dylib`g_main_context_dispatch + 258
    frame #73: 0x0000000102033a33 libglib-2.0.0.dylib`g_main_context_iterate + 426
    frame #74: 0x0000000102033c69 libglib-2.0.0.dylib`g_main_loop_run + 191
    frame #75: 0x00000001027686be libgtk-3.0.dylib`gtk_main + 74
    frame #76: 0x000000010217c079 libgtkmm-3.0.1.dylib`Gtk::Main::run(Gtk::Window&) + 157
    frame #77: 0x0000000100431895 rawtherapee`main(argc=1, argv=0x00007ffeefbff990) at main.cc:647
    frame #78: 0x00007fff63139ed9 libdyld.dylib`start + 1

(lldb) frame select 37
frame #37: 0x000000010021f69c rawtherapee`EditorPanel::saveAsPressed(this=0x000000010b33a3f0) at editorpanel.cc:1866
   1863     saveAsDialog->setImagePath (fname);
   1864 
   1865     do {
-> 1866         int result = saveAsDialog->run ();
   1867 
   1868         // The SaveAsDialog ensure that a filename has been specified
   1869         fnameOut = saveAsDialog->getFileName ();

I hope, that I will take a deeper look at it during this week.

okoncevoy commented 5 years ago

I've just tested, and in latest GIMP there is no possibility to use search in FIleChooser*, also minimal gtk3 application using only one window and file chooser dialog also crashes. Maybe it is possible to disable it also in RawTherapee (for osx)? I still want to recompile every thing with latest gtk and gtkmm. @Beep6581

Beep6581 commented 5 years ago

@lvreclp @hafilax which version of GTK+ did you reproduce it in, and have you filed a bug report upstream?

Could be this, recently fixed: https://gitlab.gnome.org/GNOME/gtk/issues/815

okoncevoy commented 5 years ago

I have used version, which is available from macports: Gtkmm: V3.22.3 and gtk3 3.22.30. I still want to try compile latest release, which is 3.24.x and re-compile RT with it, as it might be, that version 3.22.x is only affected by this bug.

Beep6581 commented 5 years ago

3.24.* are also affected by the bug I linked to. It's not clear which release the fix went into, could be 3.24.4 or even 3.24.7.

okoncevoy commented 5 years ago

@Beep6581 Do you have any plan, how we will proceed with this issue? I will try to compile with latest dev on WE

Beep6581 commented 5 years ago

@lvreclp auto-search cannot be disabled, but one could capture and block the on_key_press_event. https://github.com/Beep6581/RawTherapee/blob/dev/rtgui/saveasdlg.cc#L379 I tried that but didn't manage getting it to actually block the search, maybe you have more luck. Maybe the blocking should be done not on the Gtk::FileChooser interface but on the Gtk::FileChooserWidget or Gtk::FileChooserDialog.

Anyway the bug is likely upstream and likely fixed. If you have access to debug GTK+ libs, then maybe the backtrace would tell us more.

okoncevoy commented 5 years ago

@Beep6581 This code fixes crash in the Save as dialog, by catching all key press events on the Gtk::FileChooserWidget. Can you test this?

diff --git a/rtgui/saveasdlg.cc b/rtgui/saveasdlg.cc
index f2a7206b9..a20a984c5 100644
--- a/rtgui/saveasdlg.cc
+++ b/rtgui/saveasdlg.cc
@@ -54,7 +54,9 @@ SaveAsDialog::SaveAsDialog (const Glib::ustring &initialDir, Gtk::Window* parent
     fchooser = Gtk::manage( new Gtk::FileChooserWidget (Gtk::FILE_CHOOSER_ACTION_SAVE) );
     fchooser->set_current_folder (initialDir);
     fchooser->signal_file_activated().connect(sigc::mem_fun(*this, &SaveAsDialog::okPressed));
-
+ #ifdef __APPLE__
+    fchooser->signal_key_press_event().connect([](GdkEventKey *) -> bool { return true; }, false);
+#endif
     filter_jpg = Gtk::FileFilter::create();
     filter_jpg->set_name(M("SAVEDLG_JPGFILTER"));
     filter_jpg->add_pattern("*.jpg");

In next few days, I will update other parts of the code.

Beep6581 commented 5 years ago

@lvreclp I can confirm that your patch blocks the event successfully in Linux (without the #ifdefs). I don't access to any macOS, but hopefully @Benitoite can help test in macOS.

Now the question is what to do with this. As we don't know for sure which versions of GTK+ are affected, or which version of GTK+ it's fixed in, we could either merge it permanently, or we could just make the 5.6 macOS build use it (commit to make it part of the tarball, but then revert after tagging). What do you think?

okoncevoy commented 5 years ago

I think it is better to merge this fix for 5.6, when I will finish it and close this issue. Meanwhile open an another issue for 5.7 to not forget to revert this functionality as soon as it will be clear, which GTK+ version must be used, as this fix brings inconsistent behavior to the RT across different platforms.

Beep6581 commented 5 years ago

when I will finish it

It's not finished?

okoncevoy commented 5 years ago

No. RT have lot of filechooserdialogs and all of them crash on typing. Curves saving loading, clut directory select, dframe select. And another problem, is that filechooserdialog from GTK incapsulates inner widgets, and I didn't found for current moment how to block only search.

Beep6581 commented 5 years ago

Then it could be a better idea to not commit workarounds for possibly upstream bugs and just ask Hiram to use the latest GTK+ version when making the 5.6 build. @Benitoite could you make a test-build, and let us known which is the highest version of GTK+ available to you (or do you compile GTK+ from source)?

okoncevoy commented 5 years ago

If it is possible to compile 5.6 using fixed GTK, it is the most correct way, because yes, this is a workaround and may take more than one line to fix it everywhere.

Beep6581 commented 4 years ago

@hafilax @lvreclp @Benitoite is this still valid?

hafilax commented 4 years ago

I'm now running version 5.6 and this issue seems to be fixed.

Here is the "AboutThisBuild.txt":

Version: 5.6 Branch: 5.6 Commit: 5a4ed7317 Commit date: 2019-04-20 Compiler: clang 10.0.1.10010046 Processor: generic x86 System: Apple Bit depth: 64 bits Gtkmm: V3.24.1 Lensfun: V0.3.95.0 Build type: release Build flags: -std=c++11 -std=c++11 -mtune=generic -Werror=unused-label -mmacosx-version-min=10.9 -flto -Wall -Wuninitialized -Wno-deprecated-declarations -Wno-unused-result -Xpreprocessor -fopenmp /opt/local/lib/libiomp5.dylib -I/opt/local/include -Werror=unknown-pragmas -O3 -DNDEBUG -ftree-vectorize Link flags: -mtune=generic -headerpad_max_install_names -flto OpenMP support: ON MMAP support: ON