plugdata-team / plugdata

Pure Data as a plugin, with a new GUI
https://plugdata.org
GNU General Public License v3.0
1.59k stars 67 forks source link

can't close text dialog #1596

Open tomara-x opened 6 months ago

tomara-x commented 6 months ago

the x button doesn't work. the message works, but there's a use after free

(this only happens after you type into it)

https://github.com/plugdata-team/plugdata/assets/86204514/522872e8-2067-4f6d-b5c6-ee00b5173121

==14293==ERROR: AddressSanitizer: heap-use-after-free on address 0x61d0001f5f60 at pc 0x555556e52d80 bp 0x7fffffffc0f0 sp 0x7fffffffc0e0
READ of size 3 at 0x61d0001f5f60 thread T0
    #0 0x555556e52d7f in juce::Component::toFront(bool) /home/void/plugdata/Libraries/JUCE/modules/juce_gui_basics/components/juce_Component.cpp:610
    #1 0x555555ede2f6 in Dialog::mouseDown(juce::MouseEvent const&) /home/void/plugdata/Source/Dialogs/Dialogs.h:115
    #2 0x555556e563f5 in juce::Component::internalMouseDown(juce::MouseInputSource, juce::detail::PointerState const&, juce::Time) /home/void/plugdata/Libraries/JUCE/modules/juce_gui_basics/components/juce_Component.cpp:2191
    #3 0x55555717a8aa in juce::detail::MouseInputSourceImpl::sendMouseDown(juce::Component&, juce::detail::PointerState const&, juce::Time) /home/void/plugdata/Libraries/JUCE/modules/juce_gui_basics/detail/juce_MouseInputSourceImpl.h:135
    #4 0x55555717a8aa in juce::detail::MouseInputSourceImpl::setButtons(juce::detail::PointerState const&, juce::Time, juce::ModifierKeys) /home/void/plugdata/Libraries/JUCE/modules/juce_gui_basics/detail/juce_MouseInputSourceImpl.h:223
    #5 0x555556ea83a6 in juce::detail::MouseInputSourceImpl::handleEvent(juce::ComponentPeer&, juce::Point<float>, juce::Time, juce::ModifierKeys, float, float, juce::PenDetails) /home/void/plugdata/Libraries/JUCE/modules/juce_gui_basics/detail/juce_MouseInputSourceImpl.h:331
    #6 0x555556ea8e47 in juce::MouseInputSource::handleEvent(juce::ComponentPeer&, juce::Point<float>, long long, juce::ModifierKeys, float, float, juce::PenDetails const&) /home/void/plugdata/Libraries/JUCE/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp:80
    #7 0x555556ea8e47 in juce::ComponentPeer::handleMouseEvent(juce::MouseInputSource::InputSourceType, juce::Point<float>, juce::ModifierKeys, float, float, long long, juce::PenDetails, int) /home/void/plugdata/Libraries/JUCE/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp:90
    #8 0x555556ea93da in juce::XWindowSystem::handleButtonPressEvent(juce::LinuxComponentPeer*, XIDeviceEvent const*, int) const /home/void/plugdata/Libraries/JUCE/modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp:3688
    #9 0x555556ead064 in juce::XWindowSystem::xiMessageReceive(_XEvent&) /home/void/plugdata/Libraries/JUCE/modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp:4073
    #10 0x555556ead933 in operator() /home/void/plugdata/Libraries/JUCE/modules/juce_gui_basics/native/juce_XWindowSystem_linux.cpp:3354
    #11 0x555556ead933 in __invoke_impl<void, juce::XWindowSystem::initialiseXDisplay()::<lambda(int)>&, int> /usr/include/c++/13.2/bits/invoke.h:61
    #12 0x555556ead933 in __invoke_r<void, juce::XWindowSystem::initialiseXDisplay()::<lambda(int)>&, int> /usr/include/c++/13.2/bits/invoke.h:111
    #13 0x555556ead933 in _M_invoke /usr/include/c++/13.2/bits/std_function.h:290
    #14 0x555557459762 in std::function<void (int)>::operator()(int) const /usr/include/c++/13.2/bits/std_function.h:591
    #15 0x555557459762 in operator() /home/void/plugdata/Libraries/JUCE/modules/juce_events/native/juce_Messaging_linux.cpp:360
    #16 0x555557459762 in __invoke_impl<void, juce::LinuxEventLoop::registerFdCallback(int, std::function<void(int)>, short int)::<lambda()>&> /usr/include/c++/13.2/bits/invoke.h:61
    #17 0x555557459762 in __invoke_r<void, juce::LinuxEventLoop::registerFdCallback(int, std::function<void(int)>, short int)::<lambda()>&> /usr/include/c++/13.2/bits/invoke.h:111
    #18 0x555557459762 in _M_invoke /usr/include/c++/13.2/bits/std_function.h:290
    #19 0x5555574850b7 in std::function<void ()>::operator()() const /usr/include/c++/13.2/bits/std_function.h:591
    #20 0x5555574850b7 in juce::InternalRunLoop::dispatchPendingEvents() /home/void/plugdata/Libraries/JUCE/modules/juce_events/native/juce_Messaging_linux.cpp:180
    #21 0x5555574850b7 in juce::detail::dispatchNextMessageOnSystemQueue(bool) /home/void/plugdata/Libraries/JUCE/modules/juce_events/native/juce_Messaging_linux.cpp:342
    #22 0x55555748569e in juce::MessageManager::runDispatchLoop() /home/void/plugdata/Libraries/JUCE/modules/juce_events/messages/juce_MessageManager.cpp:112
    #23 0x555555dfa29a in juce::JUCEApplicationBase::main() /home/void/plugdata/Libraries/JUCE/modules/juce_events/messages/juce_ApplicationBase.cpp:265
    #24 0x7ffff6d22c4b in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #25 0x7ffff6d22d04 in __libc_start_main_impl ../csu/libc-start.c:360
    #26 0x555555e03940 in _start ../sysdeps/x86_64/start.S:115

0x61d0001f5f60 is located 224 bytes inside of 2096-byte region [0x61d0001f5e80,0x61d0001f66b0)
freed by thread T0 here:
    #0 0x7ffff78df400 in operator delete(void*, unsigned long) (/usr/lib64/libasan.so.8+0xdf400) (BuildId: aeba97580db176cd8372886eec9db37d06642970)
    #1 0x5555561d9ee1 in std::default_delete<juce::Component>::operator()(juce::Component*) const /usr/include/c++/13.2/bits/unique_ptr.h:99
    #2 0x5555561d9ee1 in std::__uniq_ptr_impl<juce::Component, std::default_delete<juce::Component> >::reset(juce::Component*) /usr/include/c++/13.2/bits/unique_ptr.h:211
    #3 0x5555561d9ee1 in std::unique_ptr<juce::Component, std::default_delete<juce::Component> >::reset(juce::Component*) /usr/include/c++/13.2/bits/unique_ptr.h:509
    #4 0x5555561d9ee1 in TextDefineObject::receiveObjectMessage(unsigned int, pd::Atom const*, int) /home/void/plugdata/Source/Objects/TextDefineObject.h:283
    #5 0x5555561d9ee1 in TextDefineObject::receiveObjectMessage(unsigned int, pd::Atom const*, int) /home/void/plugdata/Source/Objects/TextDefineObject.h:276

previously allocated by thread T0 here:
    #0 0x7ffff78de358 in operator new(unsigned long) (/usr/lib64/libasan.so.8+0xde358) (BuildId: aeba97580db176cd8372886eec9db37d06642970)
    #1 0x555555e94281 in Dialogs::showTextEditorDialog(juce::String const&, juce::String, std::function<void (juce::String, bool)>) /home/void/plugdata/Source/Dialogs/Dialogs.cpp:121

SUMMARY: AddressSanitizer: heap-use-after-free /home/void/plugdata/Libraries/JUCE/modules/juce_gui_basics/components/juce_Component.cpp:610 in juce::Component::toFront(bool)
Shadow bytes around the buggy address:
  0x61d0001f5c80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x61d0001f5d00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x61d0001f5d80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x61d0001f5e00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x61d0001f5e80: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
=>0x61d0001f5f00: fd fd fd fd fd fd fd fd fd fd fd fd[fd]fd fd fd
  0x61d0001f5f80: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x61d0001f6000: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x61d0001f6080: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x61d0001f6100: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x61d0001f6180: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==14293==ABORTING
timothyschoen commented 6 months ago

I think I fixed it on nightly now!

tomara-x commented 6 months ago

epic! but sadly it now opens behind the main window!

https://github.com/plugdata-team/plugdata/assets/86204514/417c515a-2626-4cf4-845f-7f1bcb6154fd

alcomposer commented 5 months ago

This looks related to #1613