juce-framework / JUCE

JUCE is an open-source cross-platform C++ application framework for desktop and mobile applications, including VST, VST3, AU, AUv3, LV2 and AAX audio plug-ins.
https://juce.com
Other
6.54k stars 1.73k forks source link

[Bug]: Memory leak when closing Reaper with the plugin window open #1386

Closed 7sharp9 closed 3 months ago

7sharp9 commented 4 months ago

Detailed steps on how to reproduce the bug

Create a plugin, e.g using the gain demo, launch Reaper, open the plugin UI, now close reaper, leaked dobjects are listed.

What is the expected behaviour?

No leaking objects

Operating systems

macOS

What versions of the operating systems?

14.5

Architectures

x86_64

Stacktrace

Leaks reported on Exit:

*** Leaked objects detected: 1 instance(s) of class OwnedArray
JUCE Assertion failure in juce_LeakedObjectDetector.h:92

*** Leaked objects detected: 1 instance(s) of class AsyncUpdater
JUCE Assertion failure in juce_LeakedObjectDetector.h:92

JUCE Assertion failure in juce_Singleton.h:50


### Plug-in formats (if applicable)

AU

### Plug-in host applications (DAWs) (if applicable)

Reaper 7.16

### Testing on the `develop` branch

The bug is present on the `develop` branch

### Code of Conduct

- [X] I agree to follow the Code of Conduct
7sharp9 commented 4 months ago

This is also detailed in this thread: https://forum.juce.com/t/memory-leaks-on-shutdown/60243

7sharp9 commented 4 months ago

Adding the Heavyweight leak detector show where the leak occurs - ModalComponentManager :

Test                     0x0000000125f0d41e _ZN4juce11SystemStats17getStackBacktraceEv + 94\r\n1   
Test                     0x0000000125b45a6d _ZN4juce31HeavyweightLeakedObjectDetectorINS_10OwnedArrayINS_21ModalComponentManager9ModalItemENS_20DummyCriticalSectionEEEEC2Ev + 29\r\n2   
Test                     0x0000000125b459c5 _ZN4juce31HeavyweightLeakedObjectDetectorINS_10OwnedArrayINS_21ModalComponentManager9ModalItemENS_20DummyCriticalSectionEEEEC1Ev + 21\r\n3   
Test                     0x0000000125b45986 _ZN4juce10OwnedArrayINS_21ModalComponentManager9ModalItemENS_20DummyCriticalSectionEEC2Ev + 38\r\n4   
Test                     0x0000000125a11205 _ZN4juce10OwnedArrayINS_21ModalComponentManager9ModalItemENS_20DummyCriticalSectionEEC1Ev + 21\r\n5   
Test                     0x0000000125a111c5 _ZN4juce21ModalComponentManagerC2Ev + 85\r\n6   Studio Standard                     0x0000000125a11225 _ZN4juce21ModalComponentManagerC1Ev + 21\r\n7   
Test                     0x0000000125b425d3 _ZN4juce15SingletonHolderINS_21ModalComponentManagerENS_20DummyCriticalSectionELb0EE18getWithoutCheckingEv + 83\r\n8   
Test                     0x0000000125a08810 _ZN4juce21ModalComponentManager11getInstanceEv + 16\r\n9   
Test                     0x00000001259f1090 _ZN4juce9Component26getCurrentlyModalComponentEi + 16\r\n10  
Test                     0x00000001258c3d64 _ZN6JuceAU15JuceUIViewClass8shutdownEP11objc_object + 212\r\n11  
Test                     0x00000001258c4131 _ZZN6JuceAU15JuceUIViewClassC1EvENKUlP11objc_objectP13objc_selectorP14NSNotificationE_clES2_S4_S6_ + 33\r\n12  
Test                     0x00000001258c4189 _ZZN6JuceAU15JuceUIViewClassC1EvENUlP11objc_objectP13objc_selectorP14NSNotificationE_8__invokeES2_S4_S6_ + 41\r\n13  
CoreFoundation                      0x00007ff816115710 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 137\r\n14  
CoreFoundation                      0x00007ff8161a6136 ___CFXRegistrationPost_block_invoke + 88\r\n15  
CoreFoundation                      0x00007ff8161a6080 _CFXRegistrationPost + 532\r\n16  
CoreFoundation                      0x00007ff8160e502b _CFXNotificationPost + 682\r\n17  
Foundation                          0x00007ff81707bd0e -[NSNotificationCenter postNotificationName:object:userInfo:] + 82\r\n18  
AppKit                              0x00007ff8199f55a6 -[NSApplication terminate:] + 1979\r\n19  
REAPER                              0x000000010affd29a _Z8MainProcP6HWND__jml + 7386\r\n20  
REAPER                              0x000000010ae4951c _ZL28SwellDialogDefaultWindowProcP6HWND__jml + 444\r\n21  
REAPER                              0x000000010a950e76 _Z16Main_OnCommandExiiP10ReaProject + 22\r\n22  
REAPER                              0x000000010ac5a845 _Z20KBD_OnMainActionImpliiiiP6HWND__P10ReaProject + 325\r\n23  
REAPER                              0x000000010ac5e298 _Z18KBD_OnMainActionExiiiiP6HWND__P10ReaProject + 136\r\n24  
REAPER                              0x000000010affca31 _Z8MainProcP6HWND__jml + 5233\r\n25  
REAPER                              0x000000010ae4951c _ZL28SwellDialogDefaultWindowProcP6HWND__jml + 444\r\n26  
AppKit                              0x00007ff81997c34d -[NSApplication(NSResponder) sendAction:to:from:] + 337\r\n27  
AppKit                              0x00007ff819a699b1 -[NSMenuItem _corePerformAction] + 455\r\n28  
AppKit                              0x00007ff81a0d1452 _NSMenuPerformActionWithHighlighting + 185\r\n29  
AppKit                              0x00007ff819aad1cb -[NSMenu performActionForItemAtIndex:] + 113\r\n30  
AppKit                              0x00007ff819aad151 -[NSMenu _internalPerformActionForItemAtIndex:] + 82\r\n31  
AppKit                              0x00007ff81a0c73f9 +[NSCocoaMenuImpl _performActionForMenuItem:] + 76\r\n32  
AppKit                              0x00007ff819ea3ce6 -[NSMenuTrackingSession _performPostTrackingDismissalActions] + 394\r\n33  
AppKit                              0x00007ff819ea39d5 -[NSMenuTrackingSession startRunningMenuEventLoop:] + 1900\r\n34  
AppKit                              0x00007ff819f662ba -[NSMenuBarTrackingSession startMonitoringEventsInMode:] + 59\r\n35  
AppKit                              0x00007ff819f652e7 -[NSMenuBarTrackingSession _mouseDownEventHandler:] + 335\r\n36  
AppKit                              0x00007ff819f65182 -[NSMenuBarTrackingSession handleEvent:] + 224\r\n37  
AppKit                              0x00007ff819f6507b __57-[NSMenuBarTrackingSession _addLocalEventMonitorIfNeeded]_block_invoke + 200\r\n38  
AppKit                              0x00007ff8199e0f1c _NSSendEventToDequeuingObservers + 323\r\n39  
AppKit                              0x00007ff81a0a3414 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2893\r\n40  
AppKit                              0x00007ff819780075 -[NSApplication run] + 603\r\n41  AppKit                              0x00007ff819753ff3 NSApplicationMain + 816\r\n42  
dyld                                0x00007ff815cb7366 start + 1942
reuk commented 3 months ago

Thanks for reporting. This issue should be resolved by the following changes:

https://github.com/juce-framework/JUCE/commit/fd01869cfd042d6cc17aeae0f8d5d10716e7c4d7 https://github.com/juce-framework/JUCE/commit/225f1526eecaf225f6b642231ac1f6c6158b97da