fdb / frequensea

Visualizing the frequency spectrum.
MIT License
169 stars 18 forks source link

Segfaults on Linux #13

Open drws opened 8 years ago

drws commented 8 years ago

I have managed to build latest frequensea on Arch Linux x64 without noticeable problems, but it segfaults upon running:

> frequensea ../lua/static.lua 
OpenGL Renderer: Mesa DRI Intel(R) Ivybridge Mobile 
OpenGL Version: 3.3 (Core Profile) Mesa 12.0.1
Segmentation fault (core dumped)

These are versions of my runtime-related libraries:

What additional info can I provide/how should this be debugged?

fdb commented 8 years ago

Hi,

Thanks for trying out! Ideally, could you try running it in gdb? If it's build with debug symbols it should give you a good stacktrace

gdb frequensea
r  ../lua/static.lua
[when it crashes]
bt

bt gives you a backtrace command, which should give us some clue where the error might be.

cokomokoo commented 8 years ago
└──>>gdb frequensea
GNU gdb (GDB) 7.12
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-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"...
Reading symbols from frequensea...(no debugging symbols found)...done.
(gdb) r  ../lua/static.lua
Starting program: /usr/bin/frequensea ../lua/static.lua
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
OpenGL Renderer: GeForce GT 230M/PCIe/SSE2
OpenGL Version: 3.2.0 NVIDIA 340.98

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
itdaniher commented 7 years ago
#0  0x0000000000000000 in ?? ()                                                                                                                                                                                                               
#1  0x00005555555882dc in ngl_model_load_obj (fname=0x555555850a70 "../obj/c004.obj") at /home/user/frequensea/src/ngl.c:467                                                                                                                  
#2  0x00005555555676b3 in l_ngl_model_load_obj(lua_State*) ()                                                                                                                                                                                 
#3  0x000055555559bc7a in luaD_precall (L=0x555555843288, func=0x555555843580, nresults=1) at /home/user/frequensea/externals/lua/src/ldo.c:337                                                                                               
#4  0x00005555555b7de6 in luaV_execute (L=0x555555843288) at /home/user/frequensea/externals/lua/src/lvm.c:991                                                                                                                                
#5  0x000055555559c132 in luaD_call (L=0x555555843288, func=0x555555843570, nResults=0, allowyield=0) at /home/user/frequensea/externals/lua/src/ldo.c:422                                                                                    
#6  0x00005555555964d5 in f_call (L=0x555555843288, ud=0x7fffffffdd30) at /home/user/frequensea/externals/lua/src/lapi.c:914                                                                                                                  
#7  0x000055555559b2f3 in luaD_rawrunprotected (L=0x555555843288, f=0x55555559649e <f_call>, ud=0x7fffffffdd30) at /home/user/frequensea/externals/lua/src/ldo.c:142                                                                          
#8  0x000055555559c8db in luaD_pcall (L=0x555555843288, func=0x55555559649e <f_call>, u=0x7fffffffdd30, old_top=16, ef=0) at /home/user/frequensea/externals/lua/src/ldo.c:644                                                                
#9  0x00005555555965a6 in lua_pcallk (L=0x555555843288, nargs=0, nresults=0, errfunc=0, ctx=0, k=0x0) at /home/user/frequensea/externals/lua/src/lapi.c:940                                                                                   
#10 0x0000555555566708 in l_call_function(lua_State*, char const*) ()                                                                                                                                                                         
#11 0x000055555556a30d in main ()      
itdaniher commented 7 years ago

OpenGL Renderer: GeForce GTX 960/PCIe/SSE2 OpenGL Version: 3.2.0 NVIDIA 375.39 Debian 9

fdb commented 7 years ago

@itdaniher this seems to be an error with loading the model. Are you executing from the correct directory? I always start up frequensea from the build directory.

itdaniher commented 7 years ago

@fdb I was too, it's possible I messed up with my gdb invocation....

In any case, I'll try again. Getting frequensea compiled wasn't too bad, and it looks like a very powerful framework for building awesome visualisations!

fdb commented 7 years ago

Thanks! Good luck and let me know if you get it to work (or if there are any issues).

itdaniher commented 7 years ago
~/native/frequensea/build(master*) » ./frequensea ../lua/static.lua
OpenGL Renderer: GeForce GTX 960/PCIe/SSE2
OpenGL Version: 3.2.0 NVIDIA 375.39
[1]    22262 segmentation fault  ./frequensea ../lua/static.lua
itdaniher commented 7 years ago

variant on the theme:

~/native/frequensea/build(master*) » ./frequensea ../lua/fft.lua
OpenGL Renderer: GeForce GTX 960/PCIe/SSE2
OpenGL Version: 3.2.0 NVIDIA 375.39
Found Rafael Micro R820T tuner
Exact sample rate is: 3000000.178814 Hz
[1]    22551 segmentation fault  ./frequensea ../lua/fft.lua
fdb commented 7 years ago

Thanks! What backtrace do you get on the FFT example?

itdaniher commented 7 years ago
#0  0x0000000000000000 in ?? ()
#1  0x000055555558674b in ngl_shader_new (draw_mode=4,
    vertex_shader_source=0x55555584ae20 "#version 400\nlayout (location = 0) in vec3 vp;\nlayout (location = 1) in vec3 vn;\nlayout (location = 2) in vec2 vt;\nout vec3 color;\nout vec2 texCoord;\nuniform mat4 uViewMatrix, uProjectionMatrix;\nunifo"...,
    fragment_shader_source=0x55555584b070 "#version 400\nin vec3 color;\nin vec2 texCoord;\nuniform sampler2D uTexture;\nlayout (location = 0) out vec4 fragColor;\nvoid main() {\n    float r = texture(uTexture, texCoord).r * 0.1;\n    fragColor = vec"...) at /home/datum/native/frequensea/src/ngl.c:102
#2  0x0000555555566f16 in l_ngl_shader_new(lua_State*) ()
#3  0x000055555559bc7a in luaD_precall (L=0x555555843288, func=0x555555843580, nresults=1) at /home/datum/native/frequensea/externals/lua/src/ldo.c:337
#4  0x00005555555b7de6 in luaV_execute (L=0x555555843288) at /home/datum/native/frequensea/externals/lua/src/lvm.c:991
#5  0x000055555559c132 in luaD_call (L=0x555555843288, func=0x555555843570, nResults=0, allowyield=0) at /home/datum/native/frequensea/externals/lua/src/ldo.c:422
#6  0x00005555555964d5 in f_call (L=0x555555843288, ud=0x7fffffffdd30) at /home/datum/native/frequensea/externals/lua/src/lapi.c:914
#7  0x000055555559b2f3 in luaD_rawrunprotected (L=0x555555843288, f=0x55555559649e <f_call>, ud=0x7fffffffdd30) at /home/datum/native/frequensea/externals/lua/src/ldo.c:142
#8  0x000055555559c8db in luaD_pcall (L=0x555555843288, func=0x55555559649e <f_call>, u=0x7fffffffdd30, old_top=16, ef=0) at /home/datum/native/frequensea/externals/lua/src/ldo.c:644
#9  0x00005555555965a6 in lua_pcallk (L=0x555555843288, nargs=0, nresults=0, errfunc=0, ctx=0, k=0x0) at /home/datum/native/frequensea/externals/lua/src/lapi.c:940
#10 0x0000555555566708 in l_call_function(lua_State*, char const*) ()
#11 0x000055555556a30d in main ()
fdb commented 7 years ago

The shaders in the fft.lua example mention #version400, which require OpenGL 4.0. You could try changing them to #version 150, which is supported on OpenGL 3.2. It's weird that it crashes, though. It should just show an error.

Does empty.lua work? That doesn't use any shaders at all.

The two errors / stack traces seem unrelated, though. Unfortunately, I can't reproduce them here (I'm on OS X right now).

fdb commented 7 years ago

I just tried backporting the shader code to OpenGL 3.2. However, it's not so simple, as the layout specifiers in the shader are needed for frequensea to figure out where to store the vertices and the normals.

For this to work, I probably need to tweak the API to pass in the shader and the attribute names (vp, vn, vt) so they can be matched up (instead of relying on the OpenGL 4 layout specifiers).

Internally, the text drawing also uses these OpenGL 4 layout specifiers, so that will need to be changed as well.

itdaniher commented 7 years ago

!empty.lua doesn't segfault!

itdaniher commented 7 years ago

This in mind, I'd be quite happy to see a OpenGL3.2 version of the relevant shaders. I don't know enough about OpenGL to know if it's feasible to upgrade my Debian 9 install to 4.0....