Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation Fault on Ubuntu 18.04 #82

Closed
zhanghongce opened this issue Dec 3, 2020 · 4 comments
Closed

Segmentation Fault on Ubuntu 18.04 #82

zhanghongce opened this issue Dec 3, 2020 · 4 comments
Labels

Comments

@zhanghongce
Copy link

zhanghongce commented Dec 3, 2020

Hi Simon

Many thanks for this nice project, I really love it.
However, I encountered a small issue when using it.
It went segmentation fault during exit.
This actually does not affect my normal use, but I think maybe I can contribute a bit by reporting this issue.

$ lsb_release -a
LSB Version:	core-9.20170808ubuntu1-noarch:printing-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.5 LTS
Release:	18.04
Codename:	bionic

$ uname -a
Linux hongce-XPS-15-9570 4.15.0-124-generic #127-Ubuntu SMP Fri Nov 6 10:54:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Graphics: Intel UHD Graphics 630(CFL GT2)
OpenGL version string: 3.0 Mesa 20.0.8
glxinfo.txt
RAM: 32GB
CPU: Intel Core i5-8300H

I compiled one from commit hash: 37807d3 tag: v5.3(1), because the pre-compiled binary does not work for me.

By enabling the debug build, I was able to locate the place of segmentation fault.

(gdb) bt
#0  0x00007fffed21bbc0 in  ()
#1  0x0000555555664763 in Framebuffer::clean() (this=0x555556204ef0) at /home/hongce/opt/moved/signal-audio/MIDIVisualizer/src/rendering/Framebuffer.cpp:85
#2  0x000055555566455e in Framebuffer::~Framebuffer() (this=0x555556204ef0, __in_chrg=<optimized out>) at /home/hongce/opt/moved/signal-audio/MIDIVisualizer/src/rendering/Framebuffer.cpp:48
#3  0x000055555567b460 in std::_Sp_counted_ptr<Framebuffer*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() (this=0x5555561f6b30) at /usr/include/c++/7/bits/shared_ptr_base.h:376
#4  0x0000555555675870 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (this=0x5555561f6b30) at /usr/include/c++/7/bits/shared_ptr_base.h:154
#5  0x000055555567453f in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() (this=0x7fffffffd928, __in_chrg=<optimized out>) at /usr/include/c++/7/bits/shared_ptr_base.h:684
#6  0x0000555555673712 in std::__shared_ptr<Framebuffer, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() (this=0x7fffffffd920, __in_chrg=<optimized out>)
    at /usr/include/c++/7/bits/shared_ptr_base.h:1123
#7  0x000055555567372e in std::shared_ptr<Framebuffer>::~shared_ptr() (this=0x7fffffffd920, __in_chrg=<optimized out>) at /usr/include/c++/7/bits/shared_ptr.h:93
#8  0x000055555566d3ac in Renderer::~Renderer() (this=0x7fffffffd020, __in_chrg=<optimized out>) at /home/hongce/opt/moved/signal-audio/MIDIVisualizer/src/rendering/Renderer.cpp:119
#9  0x0000555555699e1a in main(int, char**) (argc=1, argv=0x7fffffffdaf8) at /home/hongce/opt/moved/signal-audio/MIDIVisualizer/src/main.cpp:224
(gdb) up
#1  0x0000555555664763 in Framebuffer::clean (this=0x555556204ef0) at /home/hongce/opt/moved/signal-audio/MIDIVisualizer/src/rendering/Framebuffer.cpp:85
85		glDeleteRenderbuffers(1, &_idRenderbuffer);
(gdb) 

Here is a report from Valgrind:

==5452== Process terminating with default action of signal 11 (SIGSEGV)
==5452==  Access not within mapped region at address 0xFFCABC0
==5452==    at 0xFFCABC0: ???
==5452==    by 0x21855D: Framebuffer::~Framebuffer() (Framebuffer.cpp:48)
==5452==    by 0x22F45F: std::_Sp_counted_ptr<Framebuffer*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() (shared_ptr_base.h:376)
==5452==    by 0x22986F: std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (shared_ptr_base.h:154)
==5452==    by 0x22853E: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() (shared_ptr_base.h:684)
==5452==    by 0x227711: std::__shared_ptr<Framebuffer, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() (shared_ptr_base.h:1123)
==5452==    by 0x22772D: std::shared_ptr<Framebuffer>::~shared_ptr() (shared_ptr.h:93)
==5452==    by 0x2213AB: Renderer::~Renderer() (Renderer.cpp:119)
==5452==    by 0x24DE19: main (main.cpp:224)
==5452==  If you believe this happened as a result of a stack
==5452==  overflow in your program's main thread (unlikely but
==5452==  possible), you can try to increase the size of the
==5452==  main thread stack using the --main-stacksize= flag.
==5452==  The main thread stack size used in this run was 8388608.

I tried several MIDI files, and I got the same segmentation fault during exit, so I guess it is not relevant to the specific input, but if you think that may help, I can also attach one here.

Should you need more information, please let me know! I'm happy to help!

@zhanghongce zhanghongce added the bug label Dec 3, 2020
@zhanghongce
Copy link
Author

zhanghongce commented Dec 3, 2020

I realized that the output from cmake maybe helpful here.
cmake_output.txt
Specifically, it mentioned that:

CMake Warning (dev) at /home/hongce/local-build/cmake-3.16.2-Linux-x86_64/share/cmake-3.16/Modules/FindOpenGL.cmake:275 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  CMakeLists.txt:27 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

So I tried to add something like cmake_policy(SET CMP0072 NEW) to try the new GL library and after that the warning was gone, but that does not solve the segmentation fault issue.

kosua20 added a commit that referenced this issue Dec 3, 2020
@kosua20
Copy link
Owner

kosua20 commented Dec 3, 2020

Thank you for your feedback, and for this very detailed report! I think I have a reasonable idea of what is causing this, I've pushed a tentative fix at f6f8370 , it will be integrated in the next release.

Regarding the precompiled binary not running, I'm wondering if this is because it was compiled on Ubuntu 20. I'll try to adjust the CI pipeline to build on Ubuntu 18 instead.

@zhanghongce
Copy link
Author

zhanghongce commented Dec 3, 2020

Many thanks for your help!
I pulled that commit, compiled and ran, and confirmed it solves the issue!

Regarding the binary, actually I don't know the exact reason. I guess it is related to the libc version. Here is the error message I got:

./MIDIVisualizer: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by ./MIDIVisualizer)
./MIDIVisualizer: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by ./MIDIVisualizer)

Again, thank you for this nice project! I found that you are working on using RtMIDI to play the sound! That's really nice! Looking forward to it! I was hacking a bit previously to have it call Timidity from commandline when the first note reaches the keyboard :-)

@kosua20 kosua20 closed this as completed Dec 5, 2020
@kosua20
Copy link
Owner

kosua20 commented Dec 5, 2020

I'm happy to see that the problem was fixed!
For the issue related to the Ubuntu version I think I would have to provide a version of all dependencies compiled using the proper glibc version corresponding to Ubuntu 18, and add an extra target to the release generation.
For now RtMIDI is used to be able to receive events in real-time from another MIDI device, but I'll see if Fluidsynth or Timidity could be used for audio playback at some point in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants