steinbergmedia / vstgui

A user interface toolkit mainly for audio plug-ins
Other
880 stars 124 forks source link

bitmaps can crash the UIDescrition Editor #185

Open mxa opened 3 years ago

mxa commented 3 years ago

Having a bitmap.png of 54 x 92 pixels and a bitmap#2.0x.png with 107 x 184 pixels will crash the plugin with host when trying to open the UIDescription Edior after recompile. Resizing the scaled image to 108 x 184 pixels will make it work again. Tested on Linux (Bitwig) and Mac OS (Ableton Live). Image sizes with odd pixel dimensions will create problems.

scheffle commented 3 years ago

Callstack?

mxa commented 3 years ago

https://github.com/callstack/ ?

scheffle commented 3 years ago

If you crash, you should get a call stack or sometimes called backtrace. You should always provide this information if you file bug reports for a library you're using.

mxa commented 3 years ago

Are you saying you cannot reproduce this?

scheffle commented 3 years ago

Can you please provide a backtrace of this problem? What's so hard in doing this?

mxa commented 3 years ago
gdb bitwig
gdb run
loading plugin
[2021-01-26 00:42:41 notifications info] Loading plugins...: 
[2021-01-26 00:42:48 notifications error] Plugins Crashed: 
(gdb) backtrace
No stack.

I assume that's because bitwig runs plugins in sandboxed threads, so running gdb only gets the running parent? ok, let's try ardour6 then:

gdb ardour
GNU gdb (Ubuntu 9.2-0ubuntu2) 9.2
...
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
"/usr/bin/ardour": not in executable format: file format not recognized
(gdb) run
Starting program:  
No executable file specified.
Use the "file" or "exec-file" command.
(gdb) quit

hum, no idea.

Seriously, I have spent the whole day to pinpoint the crashes exactly to this issue, took the time to report it here for you, maybe you can take the time to give me a bit more info than "callstack?"

scheffle commented 3 years ago

OK, sorry. To create a callstack or backtrace is normally one of the first things you should get familiar with when writing software. First of all you have to make sure to generate debug symbols when compiling code. On GCC/Clang this is done with the "-g" command line switch. This should be set automatically when generating with cmake and the Debug or RelWithDebInfo build types. To make it more easy for you, you can use the editorhost example from the VST3 SDK to run your program in the debugger. Just run the gdb from the directory where you find the editorhost example with this commandline: gdb --args ./editorhost PATH_TO_YOUR_PLUGIN. If it crashes you will end up in gdb and you can enter the command "bt" to get the backtrace where it crashed.

mxa commented 3 years ago

OK, one small step at a time: Let's first confirm the editorhost is running as expected with one of the example vst3.

in /build/bin/Debug/

./editorhost ../../VST3/Debug/noteexpressionsynth.vst3/
Could not create Module for file:../VST3/Debug/noteexpressionsynth.vst3/
Could not create Module for file:../../VST3/Debug/noteexpressionsynth.vst3/
Error: dlopen failed.
../../VST3/Debug/noteexpressionsynth.vst3/Contents/x86_64-linux/..so: cannot open shared object file: No such file or directory

Maybe a Linux issue? Let's try Mac OS: (after some headstands) in /build/bin/Debug/editorhost.app/Contents/MacOS/

./editorhost ../../../../../VST3/Debug/noteexpressionsynth.vst3

success!

Next step: gdb

zsh: command not found: gdb

I'll revisit this tomorrow.

scheffle commented 3 years ago

OK, first the path on linux should be the same as the one for macOS. So use ../../VST3/Debug/noteexpressionsynth.vst3 Second, macOS uses a different debugger named 'lldb', and it's command line arguments are different. Please check the man page of it.

mxa commented 3 years ago

OK. Why is the Linux version of the editorhost not working? On the Mac OS, it's an app bundle, so I need to dig into the contents of the app package to execute it from the command line, or am I mistaken? I could not get it to run otherwise. I mean the editorhost is running on Mac OS, but fails on Linux, so I'm pretty confident the path is correct on Mac OS, I also assume the path is correct for Linux.

mxa commented 3 years ago

After some more troubleshooting I found that

./editorhost ../../VST3/Debug/noteexpressionsynth.vst3/

is failing, but

./editorhost ../../VST3/Debug/noteexpressionsynth.vst3

is opening the editorhost. (Note the removed trailing slash! Tab autocomplete will add a slash because it's a folder.)

mxa commented 3 years ago

Related: https://github.com/steinbergmedia/vstgui/issues/186

mxa commented 3 years ago

For me the editorhost is not even working with the examples, so that prevents me to provide a callstack for the above issue, because the examples crash the editorhost already.

assert at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/platform/linux/x11timer.cpp:46: Timer only works of run loop was set
editorhost: /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/vstguidebug.cpp:109: void VSTGUI::doAssert(const char*, const char*, const char*): Assertion `false' failed.

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
49      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
#1  0x00007ffff7a70864 in __GI_abort () at abort.c:79
#2  0x00007ffff7a70749 in __assert_fail_base (fmt=0x7ffff7bfc458 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x7ffff770f870 "false", 
    file=0x7ffff770f828 "/home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/vstguidebug.cpp", line=109, function=<optimized out>) at assert.c:92
#3  0x00007ffff7a82a96 in __GI___assert_fail (assertion=0x7ffff770f870 "false", 
    file=0x7ffff770f828 "/home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/vstguidebug.cpp", line=109, 
    function=0x7ffff770f7e8 "void VSTGUI::doAssert(const char*, const char*, const char*)") at assert.c:101
#4  0x00007ffff764cb1b in VSTGUI::doAssert (filename=0x7ffff77108f8 "/home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/platform/linux/x11timer.cpp", 
    line=0x7ffff771094c "46", desc=0x7ffff77108d0 "Timer only works of run loop was set") at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/vstguidebug.cpp:109
#5  0x00007ffff76680c8 in VSTGUI::X11::Timer::stop (this=0x555555b20860) at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/platform/linux/x11timer.cpp:46
#6  0x00007ffff764a6a7 in VSTGUI::CVSTGUITimer::stop (this=0x555555b1ea80) at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/cvstguitimer.cpp:80
#7  0x00007ffff764a56c in VSTGUI::CVSTGUITimer::beforeDelete (this=0x555555b1ea80) at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/cvstguitimer.cpp:54
#8  0x00007ffff738fd70 in VSTGUI::ReferenceCounted<int>::forget (this=0x555555b1ea80) at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/vstguibase.h:276
#9  0x00007ffff766ab98 in VSTGUI::Animation::Detail::Timer::~Timer (this=0x555555a1f850, __in_chrg=<optimized out>, __vtt_parm=<optimized out>)
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/animation/animator.cpp:167
#10 0x00007ffff766abf8 in VSTGUI::Animation::Detail::Timer::~Timer (this=0x555555a1f850, __in_chrg=<optimized out>, __vtt_parm=<optimized out>)
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/animation/animator.cpp:169
#11 0x00007ffff738fd8e in VSTGUI::ReferenceCounted<int>::forget (this=0x555555a1f850) at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/vstguibase.h:276
#12 0x00007ffff766a8e6 in VSTGUI::Animation::Detail::Timer::removeAnimator (animator=0x555555aa1010)
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/animation/animator.cpp:136
#13 0x00007ffff7669458 in VSTGUI::Animation::Animator::~Animator (this=0x555555aa1010, __in_chrg=<optimized out>, __vtt_parm=<optimized out>)
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/animation/animator.cpp:259
#14 0x00007ffff766949e in VSTGUI::Animation::Animator::~Animator (this=0x555555aa1010, __in_chrg=<optimized out>, __vtt_parm=<optimized out>)
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/animation/animator.cpp:260
#15 0x00007ffff738fd8e in VSTGUI::ReferenceCounted<int>::forget (this=0x555555aa1010) at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/vstguibase.h:276
#16 0x00007ffff75af0d3 in VSTGUI::SharedPointer<VSTGUI::Animation::Animator>::operator= (this=0x555555687190, _ptr=0x0)
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/vstguibase.h:443
#17 0x00007ffff75a6259 in VSTGUI::CFrame::beforeDelete (this=0x555555687010) at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/cframe.cpp:147
#18 0x00007ffff738fd70 in VSTGUI::ReferenceCounted<int>::forget (this=0x555555687010) at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/vstguibase.h:276
#19 0x00007ffff75a6493 in VSTGUI::CFrame::close (this=0x555555687010) at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/lib/cframe.cpp:195
#20 0x00007ffff73b82f6 in VSTGUI::VST3Editor::close (this=0x555555685600) at /home/max/Code/CHAIR/vst3sdk/vst3sdk/vstgui4/vstgui/plugin-bindings/vst3editor.cpp:1229
#21 0x00007ffff73ce1d6 in Steinberg::Vst::VSTGUIEditor::removed (this=0x555555685600) at /home/max/Code/CHAIR/vst3sdk/vst3sdk/public.sdk/source/vst/vstguieditor.cpp:191
#22 0x000055555556b5d7 in Steinberg::Vst::EditorHost::WindowController::closePlugView (this=0x555555686880)
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/public.sdk/samples/vst-hosting/editorhost/source/editorhost.cpp:340
#23 0x000055555556b6ec in Steinberg::Vst::EditorHost::WindowController::onClose (this=0x555555686880, w=...)
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/public.sdk/samples/vst-hosting/editorhost/source/editorhost.cpp:354
#24 0x00005555555828f4 in Steinberg::Vst::EditorHost::X11Window::Impl::handleMainWindowEvent (this=0x5555556868b0, event=...)
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/public.sdk/samples/vst-hosting/editorhost/source/platform/linux/window.cpp:854
#25 0x0000555555581608 in operator() (__closure=0x555555686d70, e=...)
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/public.sdk/samples/vst-hosting/editorhost/source/platform/linux/window.cpp:632
#26 0x00005555555840b1 in std::__invoke_impl<bool, Steinberg::Vst::EditorHost::X11Window::Impl::init(const string&, Steinberg::Vst::EditorHost::Size, bool, const WindowControllerPtr&, Display*, const WindowClosedFunc&)::<lambda(const XEvent&)>&, const _XEvent&>(std::__invoke_other, struct {...} &) (__f=...)
    at /usr/include/c++/10/bits/invoke.h:60
#27 0x0000555555583a87 in std::__invoke_r<bool, Steinberg::Vst::EditorHost::X11Window::Impl::init(const string&, Steinberg::Vst::EditorHost::Size, bool, const WindowControllerPtr&, Display*, const WindowClosedFunc&)::<lambda(const XEvent&)>&, const _XEvent&>(struct {...} &) (__fn=...) at /usr/include/c++/10/bits/invoke.h:141
#28 0x00005555555834cb in std::_Function_handler<bool(const _XEvent&), Steinberg::Vst::EditorHost::X11Window::Impl::init(const string&, Steinberg::Vst::EditorHost::Size, bool, const WindowControllerPtr&, Display*, const WindowClosedFunc&)::<lambda(const XEvent&)> >::_M_invoke(const std::_Any_data &, const _XEvent &) (__functor=..., 
    __args#0=...) at /usr/include/c++/10/bits/std_function.h:291
#29 0x0000555555579eb5 in std::function<bool (_XEvent const&)>::operator()(_XEvent const&) const (this=0x555555686d70, __args#0=...)
    at /usr/include/c++/10/bits/std_function.h:622
#30 0x0000555555577309 in Steinberg::Vst::EditorHost::RunLoop::handleEvents (this=0x5555555f3340 <Steinberg::Vst::EditorHost::RunLoop::instance()::gInstance>)
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/public.sdk/samples/vst-hosting/editorhost/source/platform/linux/runloop.cpp:133
#31 0x000055555557742e in operator() (__closure=0x555555686db0)
--Type <RET> for more, q to quit, c to continue without paging--
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/public.sdk/samples/vst-hosting/editorhost/source/platform/linux/runloop.cpp:175
#32 0x00005555555781d8 in std::__invoke_impl<void, Steinberg::Vst::EditorHost::RunLoop::start()::<lambda(int)>&, int>(std::__invoke_other, struct {...} &) (__f=...)
    at /usr/include/c++/10/bits/invoke.h:60
#33 0x0000555555577f3a in std::__invoke_r<void, Steinberg::Vst::EditorHost::RunLoop::start()::<lambda(int)>&, int>(struct {...} &) (__fn=...)
    at /usr/include/c++/10/bits/invoke.h:153
#34 0x0000555555577d50 in std::_Function_handler<void(int), Steinberg::Vst::EditorHost::RunLoop::start()::<lambda(int)> >::_M_invoke(const std::_Any_data &, int &&) (
    __functor=..., __args#0=@0x7fffffffd5f4: 3) at /usr/include/c++/10/bits/std_function.h:291
#35 0x0000555555579e18 in std::function<void (int)>::operator()(int) const (this=0x555555686db0, __args#0=3) at /usr/include/c++/10/bits/std_function.h:622
#36 0x00005555555771ba in Steinberg::Vst::EditorHost::RunLoop::select (this=0x5555555f3340 <Steinberg::Vst::EditorHost::RunLoop::instance()::gInstance>, timeout=0x0)
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/public.sdk/samples/vst-hosting/editorhost/source/platform/linux/runloop.cpp:115
#37 0x000055555557753b in Steinberg::Vst::EditorHost::RunLoop::start (this=0x5555555f3340 <Steinberg::Vst::EditorHost::RunLoop::instance()::gInstance>)
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/public.sdk/samples/vst-hosting/editorhost/source/platform/linux/runloop.cpp:182
#38 0x00005555555745ad in Steinberg::Vst::EditorHost::Platform::eventLoop (this=0x5555555f32e0 <Steinberg::Vst::EditorHost::Platform::instance()::gInstance>)
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/public.sdk/samples/vst-hosting/editorhost/source/platform/linux/platform.cpp:233
#39 0x0000555555574513 in Steinberg::Vst::EditorHost::Platform::run (this=0x5555555f32e0 <Steinberg::Vst::EditorHost::Platform::instance()::gInstance>, 
    cmdArgs=std::vector of length 1, capacity 1 = {...})
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/public.sdk/samples/vst-hosting/editorhost/source/platform/linux/platform.cpp:206
#40 0x000055555557466c in main (argc=2, argv=0x7fffffffda98)
    at /home/max/Code/CHAIR/vst3sdk/vst3sdk/public.sdk/samples/vst-hosting/editorhost/source/platform/linux/platform.cpp:254
scheffle commented 3 years ago

Hi, I don't get this crash. I just did the following:

git clone --recursive https://github.com/steinbergmedia/vst3sdk.git cd vst3sdk/ ls -al cd ../ mkdir build cd build/ cmake ../vst3sdk/ cmake --build . cd bin/ ./editorhost ../VST3/Debug/noteexpressionsynth.vst3

mxa commented 3 years ago

Can confirm. Editorhost works on Linux, but the trailing slash for the vst3 folder needs to be removed when using tab complete.

./editorhost ../VST3/Debug/noteexpressionsynth.vst3/
Error: dlopen failed.
../VST3/Debug/noteexpressionsynth.vst3/Contents/x86_64-linux/..so: cannot open shared object file: No such file or directory

but

./editorhost ../VST3/Debug/noteexpressionsynth.vst3

(no trailing slash) works.

scheffle commented 3 years ago

So now it should be possible for you to provide a call stack for the initial issue, right?

mxa commented 3 years ago

Right. I've added a new resource to the notexpressionsynth

It's vst3_logo_small#2.0x.png and has 123x80 pixels (double the size should actually be 124x80) vst3_logo_small#2 0x

$ gdb --args ./editorhost ~/.vst3/noteexpressionsynth.vst3

Reading symbols from ./editorhost...
(gdb) run
Starting program: /vst3sdk/build/bin/editorhost /home/max/.vst3/noteexpressionsynth.vst3
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

assert at /vst3sdk/vst3sdk/vstgui4/vstgui/lib/cbitmap.cpp:143: wrong bitmap size
editorhost: /vst3sdk/vst3sdk/vstgui4/vstgui/lib/vstguidebug.cpp:109: void VSTGUI::doAssert(const char*, const char*, const char*): Assertion `false' failed.

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
49      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.

In conclusion: Using the editorhost we are receiving an output which gives us a clue what's the problem: wrong bitmap size. That's at least something.

mxa commented 1 year ago

@scheffle what's unclear about this issue?