blitToWindow crashing


#1

I added a small Lua debugger for my app, Lua is in the same thread as the main thread (there are no new threads created for lua state or anything like that).

 

Anyway some Lua code is used to draw stuff using bound JUCE callbacks, when i set a breakpoint in Lua in one of those paint() callbacks, my app crashes at line 653 of juce_linux_Windowing.cpp

Here is some debugger output from my application, you can see the segfault happening. Right after a new thread gets created, but it's not my thread i imagine this is sometbing that JUCE Is doing inernaly. Also my debugger is a modal window, because i want to stop anything happening on my application while i'm stepping through the Lua code.

Is it possible that there is some clash, maybe something i can work around ?

[debug][string "drawMeBackgrounbd"]:7 in function '<[string "drawMeBackgrounbd"]:5>'
[debug]debugger.lua>
[debug]CtrlrPanelWindowManager::windowClosedButtonPressed
[debug]to debugger->c
[debug][string "drawMeBackgrounbd"]:8 in function '<[string "drawMeBackgrounbd"]:5>'
[debug]debugger.lua>
[debug][New Thread 0x7fffe3fff700 (LWP 26604)]
[debug]Program received signal SIGSEGV, Segmentation fault.
[debug]0x000000000076802b in juce::XBitmapImage::blitToWindow (this=0x0, window=60817421, dx=0, dy=24, dw=599, dh=399, sx=0, sy=0) at /home/r.kubiak/devel/ctrlr/Juce/modules/juce_gui_basics/native/juce_linux_Windowing.cpp:653
[debug]/home/r.kubiak/devel/ctrlr/Juce/modules/juce_gui_basics/native/juce_linux_Windowing.cpp:653:23182:beg:0x76802b
[debug]>>>>>>cb_gdb:

Program received signal SIGSEGV, Segmentation fault.
At /home/r.kubiak/devel/ctrlr/Juce/modules/juce_gui_basics/native/juce_linux_Windowing.cpp:653

[debug]> bt 30
[debug]#0  0x000000000076802b in juce::XBitmapImage::blitToWindow (this=0x0, window=60817421, dx=0, dy=24, dw=599, dh=399, sx=0, sy=0) at /home/r.kubiak/devel/ctrlr/Juce/modules/juce_gui_basics/native/juce_linux_Windowing.cpp:653
[debug]#1  0x000000000076c1ea in juce::LinuxComponentPeer::LinuxRepaintManager::performAnyPendingRepaintsNow (this=0x2eee070) at /home/r.kubiak/devel/ctrlr/Juce/modules/juce_gui_basics/native/juce_linux_Windowing.cpp:1916
[debug]#2  0x000000000076bc8d in juce::LinuxComponentPeer::LinuxRepaintManager::timerCallback (this=0x2eee070) at /home/r.kubiak/devel/ctrlr/Juce/modules/juce_gui_basics/native/juce_linux_Windowing.cpp:1844
[debug]#3  0x00000000005c20ef in juce::Timer::TimerThread::callTimers (this=0x2ef1ad0) at /home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/timers/juce_Timer.cpp:127
[debug]#4  0x00000000005c2349 in juce::Timer::TimerThread::CallTimersMessage::messageCallback (this=0x7fffdc0008e0) at /home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/timers/juce_Timer.cpp:198
[debug]#5  0x00000000005c3d85 in juce::InternalMessageQueue::dispatchNextInternalMessage (this=0x2ee13d0) at /home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/native/juce_linux_Messaging.cpp:202
[debug]#6  0x00000000005c37b2 in juce::InternalMessageQueue::dispatchNextEvent (this=0x2ee13d0) at /home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/native/juce_linux_Messaging.cpp:93
[debug]#7  0x00000000005c1153 in juce::MessageManager::dispatchNextMessageOnSystemQueue (returnIfNoPendingMessages=false) at /home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/native/juce_linux_Messaging.cpp:388
[debug]#8  0x00000000005bd29c in juce::MessageManager::runDispatchLoopUntil (this=0x2ee0eb0, millisecondsToRunFor=-1) at /home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/messages/juce_MessageManager.cpp:99
[debug]#9  0x00000000005bd22d in juce::MessageManager::runDispatchLoop (this=0x2ee0eb0) at /home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/messages/juce_MessageManager.cpp:86
[debug]#10 0x00000000005bc8a7 in juce::JUCEApplicationBase::main () at /home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/messages/juce_ApplicationBase.cpp:240
[debug]#11 0x00000000005bc7be in juce::JUCEApplicationBase::main (argc=1, argv=0x7fffffffe6b8) at /home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/messages/juce_ApplicationBase.cpp:218
[debug]#12 0x000000000090d35f in main (argc=1, argv=0x7fffffffe6b8) at /home/r.kubiak/devel/ctrlr/Source/Core/StandaloneWrapper/CtrlrStandaloneApplication.cpp:133
[debug]>>>>>>cb_gdb:

 


#2

It's calling blitToWindow with a null pointer, which shouldn't be able to happen. Perhaps something else is managing to call some windowing code on a background thread?


#3

Well the window is modal and the drawing is done in Lua, but no NEW threads are created in my code it's all in the main GUI thread.

 

However


[debug][New Thread 0x7fffe3fff700 (LWP 26604)]
 

that line makes me wonder what is spawning a new thread at this point, i KNOW it's not my code at any point. THere are no background threads that would do that, it's just that the lua state is in debug state and i'm stepping over instructions.


#4

Here is the stack trace:

#0 0x76802b    juce::XBitmapImage::blitToWindow(this=0x0, window=60817421, dx=0, dy=0, dw=1827, dh=678, sx=0, sy=0) (/home/r.kubiak/devel/ctrlr/Juce/modules/juce_gui_basics/native/juce_linux_Windowing.cpp:653)
#1 0x76c1ea    juce::LinuxComponentPeer::LinuxRepaintManager::performAnyPendingRepaintsNow(this=0x2eef070) (/home/r.kubiak/devel/ctrlr/Juce/modules/juce_gui_basics/native/juce_linux_Windowing.cpp:1916)
#2 0x76bc8d    juce::LinuxComponentPeer::LinuxRepaintManager::timerCallback(this=0x2eef070) (/home/r.kubiak/devel/ctrlr/Juce/modules/juce_gui_basics/native/juce_linux_Windowing.cpp:1844)
#3 0x5c20ef    juce::Timer::TimerThread::callTimers(this=0x2ef2ad0) (/home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/timers/juce_Timer.cpp:127)
#4 0x5c2349    juce::Timer::TimerThread::CallTimersMessage::messageCallback(this=0x7fffdc0008e0) (/home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/timers/juce_Timer.cpp:198)
#5 0x5c3d85    juce::InternalMessageQueue::dispatchNextInternalMessage(this=0x2ee23d0) (/home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/native/juce_linux_Messaging.cpp:202)
#6 0x5c37d0    juce::InternalMessageQueue::dispatchNextEvent(this=0x2ee23d0) (/home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/native/juce_linux_Messaging.cpp:95)
#7 0x5c1153    juce::MessageManager::dispatchNextMessageOnSystemQueue(returnIfNoPendingMessages=false) (/home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/native/juce_linux_Messaging.cpp:388)
#8 0x5bd29c    juce::MessageManager::runDispatchLoopUntil(this=0x2ee1eb0, millisecondsToRunFor=-1) (/home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/messages/juce_MessageManager.cpp:99)
#9 0x5bd22d    juce::MessageManager::runDispatchLoop(this=0x2ee1eb0) (/home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/messages/juce_MessageManager.cpp:86)
#10 0x5bc8a7    juce::JUCEApplicationBase::main() (/home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/messages/juce_ApplicationBase.cpp:240)
#11 0x5bc7be    juce::JUCEApplicationBase::main(argc=1, argv=0x7fffffffe6b8) (/home/r.kubiak/devel/ctrlr/Juce/modules/juce_events/messages/juce_ApplicationBase.cpp:218)
#12 0x90d35f    main(argc=1, argv=0x7fffffffe6b8) (/home/r.kubiak/devel/ctrlr/Source/Core/StandaloneWrapper/CtrlrStandaloneApplication.cpp:133)

 


#5

Probably just the timer thread.


#6

No idea how your code could do anything to interact with the internal paint stuff unless you're using a dangling pointer as a component or messing up memory.


#7

It's hard to say what lua is doing in terms of debugging itself i'm sure it's doing something to memory, i'll have a look on other platforms to see if similar stuff happens or is it something that's linux specific.