danomatika / ofxLua

(maintained) a lua scripting interface & bindings for openFrameworks
Other
164 stars 36 forks source link

ofxLua projects compiled for debugging crashes on start #58

Closed danomatika closed 3 years ago

danomatika commented 4 years ago

Bringing this over from #57


Hi, I just tried to run luaExample on Arch Linux and it crashes silently. In the debugger I see this:

1  glm::vec<4, float, (glm::qualifier)0> glm::operator *<float, (glm::qualifier)0>(glm::vec<4, float, (glm::qualifier)0> const&, float const&)                                                                                   type_vec4.inl                                                                          866  0x5555559444d8 
2  glm::mat<4, 4, float, (glm::qualifier)0> glm::translate<float, (glm::qualifier)0>(glm::mat<4, 4, float, (glm::qualifier)0> const&, glm::vec<3, float, (glm::qualifier)0> const&)                                              matrix_transform.inl                                                                   13   0x555555a1c2b6 
3  ofNode::createMatrix()                                                                                                                                                                                                        ofNode.cpp                                                                             676  0x555555b6cb12 
4  ofNode::setPosition(glm::vec<3, float, (glm::qualifier)0> const&)                                                                                                                                                             ofNode.cpp                                                                             182  0x555555b6a191 
5  ofNode::ofNode()                                                                                                                                                                                                              ofNode.cpp                                                                             13   0x555555b69399 
6  of3dPrimitive::of3dPrimitive()                                                                                                                                                                                                of3dPrimitives.cpp                                                                     20   0x555555b4f599 
7  ofPlanePrimitive::ofPlanePrimitive(float, float, int, int, ofPrimitiveMode)                                                                                                                                                   of3dPrimitives.cpp                                                                     294  0x555555b50cc1 
8  of3dGraphics::of3dGraphics(ofBaseRenderer *)                                                                                                                                                                                  of3dGraphics.cpp                                                                       32   0x555555b33fb6 
9  ofGLRenderer::ofGLRenderer(ofAppBaseWindow const *)                                                                                                                                                                           ofGLRenderer.cpp                                                                       24   0x555555cba9a9 
10 void __gnu_cxx::new_allocator<ofGLRenderer>::construct<ofGLRenderer, ofAppGLFWWindow *>(ofGLRenderer *, ofAppGLFWWindow *&&)                                                                                                  new_allocator.h                                                                        147  0x555555c3a879 
11 void std::allocator_traits<std::allocator<ofGLRenderer>>::construct<ofGLRenderer, ofAppGLFWWindow *>(std::allocator<ofGLRenderer>&, ofGLRenderer *, ofAppGLFWWindow *&&)                                                      alloc_traits.h                                                                         484  0x555555c3a5b6 
12 std::_Sp_counted_ptr_inplace<ofGLRenderer, std::allocator<ofGLRenderer>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<ofAppGLFWWindow *>(std::allocator<ofGLRenderer>, ofAppGLFWWindow *&&)                           shared_ptr_base.h                                                                      548  0x555555c3a124 
13 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<ofGLRenderer, std::allocator<ofGLRenderer>, ofAppGLFWWindow *>(ofGLRenderer *&, std::_Sp_alloc_shared_tag<std::allocator<ofGLRenderer>>, ofAppGLFWWindow *&&) shared_ptr_base.h                                                                      679  0x555555c39aca 
14 std::__shared_ptr<ofGLRenderer, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<ofGLRenderer>, ofAppGLFWWindow *>(std::_Sp_alloc_shared_tag<std::allocator<ofGLRenderer>>, ofAppGLFWWindow *&&)                      shared_ptr_base.h                                                                      1344 0x555555c395f2 
15 std::shared_ptr<ofGLRenderer>::shared_ptr<std::allocator<ofGLRenderer>, ofAppGLFWWindow *>(std::_Sp_alloc_shared_tag<std::allocator<ofGLRenderer>>, ofAppGLFWWindow *&&)                                                      shared_ptr.h                                                                           359  0x555555c39005 
16 std::shared_ptr<ofGLRenderer> std::allocate_shared<ofGLRenderer, std::allocator<ofGLRenderer>, ofAppGLFWWindow *>(std::allocator<ofGLRenderer> const&, ofAppGLFWWindow *&&)                                                   shared_ptr.h                                                                           702  0x555555c38595 
17 std::shared_ptr<ofGLRenderer> std::make_shared<ofGLRenderer, ofAppGLFWWindow *>(ofAppGLFWWindow *&&)                                                                                                                          shared_ptr.h                                                                           718  0x555555c37d32 
18 ofAppGLFWWindow::setup(ofGLFWWindowSettings const&)                                                                                                                                                                           ofAppGLFWWindow.cpp                                                                    204  0x555555c329dd 
19 ofAppGLFWWindow::setup(ofGLWindowSettings const&)                                                                                                                                                                             ofAppGLFWWindow.cpp                                                                    149  0x555555c324a4 
20 ofAppBaseGLWindow::setup(ofWindowSettings const&)                                                                                                                                                                             ofAppBaseWindow.h                                                                      113  0x555555c375c1 
21 ofMainLoop::createWindow(ofWindowSettings const&)                                                                                                                                                                             ofMainLoop.cpp                                                                         69   0x555555c3b026 
22 ofCreateWindow(ofWindowSettings const&)                                                                                                                                                                                       ofAppRunner.cpp                                                                        222  0x555555c2a2f8 
23 ofSetupOpenGL(int, int, ofWindowMode)                                                                                                                                                                                         ofAppRunner.cpp                                                                        217  0x555555c2a25e 
24 main                                                                                                                                                                                                                          main.cpp                                                                               15   0x555555a78a79 
25 __libc_start_main                                                                                                                                                                                                             (x86_64) /usr/lib/libc.so.6                                                                 0x7ffff598d153 
26 _start                                                                                                                                                                                                                        (x86_64) /home/fp/src/openFrameworks/addons/ofxLua/luaExample/bin/luaExample_debug      0x5555555d6dae 

Any ideas?

Originally posted by @hamoid in https://github.com/danomatika/ofxLua/issues/57#issuecomment-576026419


I'm just running luaExample unmodified, I don't know which script it is running. It's my first attempt at ofxLua. This is the output:

10:29:25: Starting /home/fp/src/openFrameworks/addons/ofxLua/luaExample/bin/luaExample_debug ...
ANOM_ABEND auid=1000 uid=1000 gid=1000 ses=1 pid=22528 comm="luaExample_debu" exe="/home/fp/src/openFrameworks/addons/ofxLua/luaExample/bin/luaExample_debug" sig=11 res=1
10:29:25: The program has unexpectedly finished.
10:29:25: The process was ended forcefully.
10:29:25: /home/fp/src/openFrameworks/addons/ofxLua/luaExample/bin/luaExample_debug crashed.

So it compiles fine and closes immediately. Can I help figure it out?

update: based on this

    scripts.push_back("scripts/graphicsExample.lua");
    scripts.push_back("scripts/imageLoaderExample.lua");
    scripts.push_back("scripts/polygonExample.lua");
    scripts.push_back("scripts/fontsExample.lua");
    currentScript = 0;

it is running graphicsExample.lua. Changing currentScript to 1, 2 or 3 also crash.

Originally posted by @hamoid

danomatika commented 4 years ago

@hamoid Does it crash if there are "no scripts" run? ie. comment out doScript() in ofApp::setup()

hamoid commented 4 years ago

Hi! It does still crash. One by one I removed all lines the lines that have something to do with lua and it still crashes. Then I realized it crashes inside ofSetupOpenGL(1024, 768, OF_WINDOW); as soon as the addon is included in the qbs file (QtCreator):

    of.addons: [ 'ofxLua' ]

If I remove the addon then it runs. Is the addon maybe redefining something that breaks glm?

jildertviet commented 4 years ago

Hi, Having the same issue on OSX (10.15.6) w/ OF 0.11.0.

#0  0x00000001001c01af in glm::detail::compute_vec4_mul<float, (glm::qualifier)0, false>::call(glm::vec<4, float, (glm::qualifier)0> const&, glm::vec<4, float, (glm::qualifier)0> const&) at /of_v0.11.0_osx_release/libs/glm/include/glm/detail/type_vec4.inl:31
#1  0x00000001003b8227 in glm::vec<4, float, (glm::qualifier)0>& glm::vec<4, float, (glm::qualifier)0>::operator*=<float>(glm::vec<4, float, (glm::qualifier)0> const&) at /of_v0.11.0_osx_release/libs/glm/include/glm/detail/type_vec4.inl:597
#2  0x00000001003b81d0 in glm::vec<4, float, (glm::qualifier)0> glm::operator*<float, (glm::qualifier)0>(glm::vec<4, float, (glm::qualifier)0> const&, glm::vec<4, float, (glm::qualifier)0> const&) at /of_v0.11.0_osx_release/libs/glm/include/glm/detail/type_vec4.inl:890
#3  0x00000001003ba196 in glm::detail::compute_inverse<4, 4, float, (glm::qualifier)0, false>::call(glm::mat<4, 4, float, (glm::qualifier)0> const&) at /of_v0.11.0_osx_release/libs/glm/include/glm/detail/func_matrix.inl:334
#4  0x000000010092488d in glm::mat<4, 4, float, (glm::qualifier)0> glm::inverse<4, 4, float, (glm::qualifier)0>(glm::mat<4, 4, float, (glm::qualifier)0> const&) [inlined] at /of_v0.11.0_osx_release/libs/glm/include/glm/detail/func_matrix.inl:391
#5  0x0000000100924888 in ofMatrixStack::loadViewMatrix(glm::mat<4, 4, float, (glm::qualifier)0> const&) at /of_v0.11.0_osx_release/libs/openFrameworks/utils/ofMatrixStack.cpp:423
#6  0x00000001008e31de in ofGLRenderer::loadViewMatrix(glm::mat<4, 4, float, (glm::qualifier)0> const&) at /of_v0.11.0_osx_release/libs/openFrameworks/gl/ofGLRenderer.cpp:996
#7  0x00000001008e2961 in ofGLRenderer::setupScreenPerspective(float, float, float, float, float) at /of_v0.11.0_osx_release/libs/openFrameworks/gl/ofGLRenderer.cpp:770
#8  0x000000010091c9a3 in ofAppGLFWWindow::setup(ofGLFWWindowSettings const&) at /of_v0.11.0_osx_release/libs/openFrameworks/app/ofAppGLFWWindow.cpp:365
#9  0x000000010091bec6 in ofAppGLFWWindow::setup(ofGLWindowSettings const&) at /of_v0.11.0_osx_release/libs/openFrameworks/app/ofAppGLFWWindow.cpp:149
#10 0x000000010089acf4 in ofMainLoop::createWindow(ofWindowSettings const&) at /of_v0.11.0_osx_release/libs/openFrameworks/app/ofMainLoop.cpp:69
#11 0x0000000100844e6b in ofCreateWindow(ofWindowSettings const&) [inlined] at /of_v0.11.0_osx_release/libs/openFrameworks/app/ofAppRunner.cpp:222
#12 0x0000000100844e51 in ofSetupOpenGL(int, int, ofWindowMode) at /of_v0.11.0_osx_release/libs/openFrameworks/app/ofAppRunner.cpp:217
#13 0x0000000100001d89 in main at /of_v0.11.0_osx_release/addons/ofxLua/luaExample/src/main.cpp:15

So it also crashes at the vec4 multiplier...

jildertviet commented 4 years ago

Ah, compiling without XCode (11.6), and just using make works...

danomatika commented 4 years ago

@jivido Sometimes I see that in Xcode and simply re-run the build a couple times, then it will build ok. It's weird, I know... all that C++ templating black magic. Scratch that, you're referring to a run time crash as opposed to compile error?

jildertviet commented 4 years ago

Ah, building in Release mode also works! However, rebuilding the Debug version doesn't seem to work...

danomatika commented 3 years ago

As a follow up, I see this all the time and simply test in release mode. Still not sure why the debug build is causing this.

frozenbears commented 3 years ago

@danomatika I don't know if this helps or just adds to the mystery, but on my machine (2013 era Macbook running High Sierra and Xcode 10) the problem goes away for the debug scheme if optimizations are turned on at level -O2 or higher.

danomatika commented 3 years ago

This appears to be caused by the glm used by the bindings not initializing vector values in the empty constructors which leads to memory corruption. Setting the #define GLM_FORCE_CTOR_INIT in the glm.i SWIG interface appears to be the fix.

danomatika commented 3 years ago

Now fixed with updated bindings in ofxLua 1.4.4.