Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 01-04-2023, 11:10 AM   #1
reuk
Human being with feelings
 
Join Date: Jan 2021
Posts: 10
Default Segfault when destroying JUCE LV2 plug-in on macOS while editor is visible

I'm not sure whether this is a bug on JUCE's side, or in REAPER, but at the moment I'm leaning towards it being REAPER's problem.

To reproduce the issue, on macOS, load a JUCE LV2 plug-in on a new channel. Then, with the plug-in's editor open, right-click on the insert and select "Delete FX". REAPER will then crash.

On debugging this, it looks like the crash happens when cleaning up the autorelease pool after handling the mouse click event that causes the FX to be deleted. The stack trace usually goes through a few `NSView` members just before the crash, so I assume that the problem involves the FX editor. When I stick a breakpoint on `dlclose`, I notice that the DLL is unloaded before the autorelease pool is cleaned up. My theory at the moment is that the autorelease pool tries to call a `release` or `dealloc` implementation from the shared library, which fails because the library is no longer loaded.

Again, I'm not sure whether this is something that can be solved on JUCE's side, but I suspect not. At the moment, I can see that `autorelease` is being called on the JUCE NSView inside a stack trace like the following:

Code:
[AppKit] -[NSView _setSuperview:] 0x00007ff8164ba38a
[AppKit] -[NSView removeFromSuperview] 0x00007ff8164dec68
[REAPER] lv2_plugin::QuitConfig() 0x0000000104731cf5
[REAPER] FxDsp::~FxDsp() 0x00000001044c3e08
[REAPER] FxChain::removeDspFromChain(int, bool) 0x00000001044e4b94
[REAPER] MediaTrack::DoMixerFxMenu(HWND__*, POINT, int, int) 0x0000000104392ac6
[REAPER] DoFXParmClick(HWND__*, long, MediaTrack*, bool, bool, WDL_VWnd*) 0x00000001046dd591
[REAPER] MediaTrack::OnTrackPanelRightClick(HWND__*, int, int, int) 0x00000001043913f5
[REAPER] MCPDisplayProc(HWND__*, unsigned int, unsigned long, long) 0x00000001046ec6cf
[REAPER] DefWindowProc(HWND__*, unsigned int, unsigned long, long) 0x000000010465cbd3
[REAPER] MCPDisplayProc(HWND__*, unsigned int, unsigned long, long) 0x00000001046ec949
[REAPER] SWELL_SendMouseMessage(REAPERSwell_hwnd*, int, NSEvent*) 0x0000000104631f2c
[AppKit] -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] 0x00007ff8165ff654
[AppKit] -[NSWindow(NSEventRouting) sendEvent:] 0x00007ff8165fea6f
[AppKit] -[NSApplication(NSEvent) sendEvent:] 0x00007ff8165fcdde
[REAPER] -[REAPERapp sendEvent:] 0x0000000104476f9b
[AppKit] -[NSApplication _handleEvent:] 0x00007ff8168bb885
[AppKit] -[NSApplication run] 0x00007ff81648c41c
[AppKit] NSApplicationMain 0x00007ff816460427
[dyld] start 0x00007ff812f42310
I don't know exactly where the nearest enclosing autorelease pool would be at this point, but it seems to be the one in `[NSApplication run]`. Perhaps adding an autorelease pool around the `removeFromSuperview` call would allow any objects autoreleased by the system to be cleaned up before `dlclose` is called.

It would be great if someone could try this out and confirm the problem. Please let me know if you need any further details, or need a plugin for testing.
reuk is offline   Reply With Quote
Old 01-04-2023, 12:46 PM   #2
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 16,202
Default

Ah, yeah it looks like we should create an autorelease pool when destroying the UI (we do this for VST/AU but not for lv2)... Of course, technically bundles on macOS can _never_ safely be unloaded, so maybe the issue is that we unload them at all.

Let me see if I can duplicate...
Justin is offline   Reply With Quote
Old 01-04-2023, 02:22 PM   #3
Fergler
Human being with feelings
 
Fergler's Avatar
 
Join Date: Jan 2014
Posts: 5,336
Default

May be related, the DecentSampler plugin (made with JUCE) will crash Reaper if you delete it while it is loading a preset.
Fergler is offline   Reply With Quote
Old 01-04-2023, 02:31 PM   #4
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 16,202
Default

(spends some time trying to build a lv2 with JUCE)

...

ok let me try a fix for the next +dev and let someone else test

tomorrow's +dev build will have two fixes, either of which should fix probably

Last edited by Justin; 01-04-2023 at 02:57 PM.
Justin is offline   Reply With Quote
Old 01-06-2023, 10:25 AM   #5
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 16,202
Default

Hello again!

Can you try the latest +dev build (see the pre-release forum) and see if this fixes your issue?

Thanks!
Justin is offline   Reply With Quote
Old 01-06-2023, 01:16 PM   #6
Fergler
Human being with feelings
 
Fergler's Avatar
 
Join Date: Jan 2014
Posts: 5,336
Default

This is not my thread, but just letting you know that didn't fix my case with DS. Here is a pastern (from a previous version of Reaper, mind you, but same crash).
https://pastebin.com/83Yawf49
Fergler is offline   Reply With Quote
Old 01-08-2023, 09:09 PM   #7
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 16,202
Default

We only updated the lv2 code, which would not affect AUs
Justin is offline   Reply With Quote
Old 01-09-2023, 10:44 AM   #8
reuk
Human being with feelings
 
Join Date: Jan 2021
Posts: 10
Default

Quote:
Originally Posted by Justin View Post
Hello again!

Can you try the latest +dev build (see the pre-release forum) and see if this fixes your issue?
I've tried build +dev0109 and it does indeed resolve the issue.

Thanks for the speedy fix!
reuk is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:49 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.