Module works fine in patch but library view crashes

Hey all - working on a new module. It was working fine in library view early on. It still loads + works properly in my patch without issue, but now when I open the library view (e.g. on right click) VCVRack crashes. The crash report is pretty generic (and at least to my eyes unhelpful):

Exception Type:        EXC_BAD_ACCESS (SIGABRT)
Exception Codes:       KERN_INVALID_ADDRESS at 0x000000000000017c
Exception Note:        EXC_CORPSE_NOTIFY

VM Regions Near 0x17c:
--> 
    __TEXT                         6a7000-e54000       [ 7860K] r-x/rwx SM=COW  /Applications/VCV Rack 2 Free.app/Contents/Resources/libRack.dylib

Application Specific Information:
abort() called

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   ???                           	0x00007ffe9464a8f4 ???
1   libsystem_kernel.dylib        	0x00007fff203eb92e __pthread_kill + 10
2   libsystem_c.dylib             	0x00007fff2036f406 abort + 125
3   com.vcvrack.rack              	0x000000010069950e fatalSignalHandler(int) + 366
4   libsystem_platform.dylib      	0x00007fff2045fd7d _sigtramp + 29
5   ???                           	0x0000000000006f03 0 + 28419
6   libRack.dylib                 	0x00000000007e2dea rack::window::Window::step() + 1578
7   libRack.dylib                 	0x00000000007e27a8 rack::window::Window::run() + 40
8   com.vcvrack.rack              	0x0000000100698fc9 main + 2649
9   libdyld.dylib                 	0x00007fff20435f3d start + 1

etc…

I’ve made enough changes now that I can’t figure out what might be causing it. Has anyone run into issues with crashes in the Library view specifically? Perhaps an issue with rendering the thumbnail preview? I’ve searched around the forums + Google and no luck. My module loads some external files, no idea if that’s related somehow…

Many thanks!

It’s a very common issue. The module browser renders the plugin with module undefined. Any dereferences of the module pointer inside the widget will crash VCV. There are various ways to deal with this, but the most common one is protecting such calls with if (module) {...}.

2 Likes

That was exactly the issue! Wrapping it in if (module) {...} worked perfectly.

Many thanks, been tearing my hair out over this. Very happy to see the module in my library once more (and be able to edit patches again :sweat_smile: )

1 Like

If you run under the debugger it will tell you exactly what happened when you crash.