Board index FlightGear Development Canvas

Segmentation fault (possibly on loading SVG file)

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

Segmentation fault (possibly on loading SVG file)

Postby omega95 » Sat Jul 26, 2014 3:27 am

While working on the A380 ECAM (E/WD and SD) displays, I found that Flightgear segfaulted a lot, especially when I changed the page (either manually or automatically - like when the APU master sw is turned on), so I installed gdb and tried to replicate and it wasn't very difficult - the first page switch I made caused a Segfault. there weren't any nasal errors, but the backtrace gave this -

Code: Select all
Program received signal SIGSEGV, Segmentation fault.
0x0000000000ed9e62 in simgear::canvas::Element::getParentStyle(SGPropertyNode const*) const ()
(gdb)


So, any idea how to fix this? :)
Merlion Virtual Airlines - the experience of a flight time...
Get high quality aircraft, airports, video tutorials or development tools from my hangar.
omega95
 
Posts: 1223
Joined: Sat Jul 30, 2011 12:59 am
Location: -unknown-
Callsign: MIA0001, OM-EGA
IRC name: omega95
Version: 2.12 git
OS: Ubuntu 13.04

Re: Segmentation fault (possibly on loading SVG file)

Postby TheTom » Sat Jul 26, 2014 5:18 pm

Which version of FG are you using? I've fixed a bug in this area in git some weeks ago.
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 10:20 am

Re: Segmentation fault (possibly on loading SVG file)

Postby omega95 » Sat Jul 26, 2014 5:23 pm

Pulled 3 days ago. :?
Merlion Virtual Airlines - the experience of a flight time...
Get high quality aircraft, airports, video tutorials or development tools from my hangar.
omega95
 
Posts: 1223
Joined: Sat Jul 30, 2011 12:59 am
Location: -unknown-
Callsign: MIA0001, OM-EGA
IRC name: omega95
Version: 2.12 git
OS: Ubuntu 13.04

Re: Segmentation fault (possibly on loading SVG file)

Postby Hooray » Sat Jul 26, 2014 5:25 pm

a tiny snippet of Nasal code to reproduce this would be helpful, as well as a full back trace
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11959
Joined: Tue Mar 25, 2008 8:40 am

Re: Segmentation fault (possibly on loading SVG file)

Postby omega95 » Sat Jul 26, 2014 6:39 pm

as well as a full back trace


What exactly would that look like?

Btw, I'm not entirely sure I know what small snippet reproduces this error. :|

But I have a feeling, it's from:
Code: Select all
me.menuObjects.removeAllChildren();
         canvas.parsesvg(me.menuObjects, me.menus[menu].path, {'font-mapper':font_mapper});
Merlion Virtual Airlines - the experience of a flight time...
Get high quality aircraft, airports, video tutorials or development tools from my hangar.
omega95
 
Posts: 1223
Joined: Sat Jul 30, 2011 12:59 am
Location: -unknown-
Callsign: MIA0001, OM-EGA
IRC name: omega95
Version: 2.12 git
OS: Ubuntu 13.04

Re: Segmentation fault (possibly on loading SVG file)

Postby Hooray » Sat Jul 26, 2014 6:54 pm

What exactly would that look like?

http://wiki.flightgear.org/Troubleshoot ... Backtraces
Code: Select all
Segmentation fault:

#0  0x0000000000f898ad in simgear::canvas::Element::getParentStyle(SGPropertyNode const*) const ()
#1  0x0000000000f899ec in simgear::canvas::Element::childRemoved(SGPropertyNode*, SGPropertyNode*) ()
#2  0x00000000011b4731 in SGPropertyNode::fireChildrenRemovedRecursive() ()
#3  0x00000000011aedb7 in simgear::PropertyBasedMgr::childRemoved(SGPropertyNode*, SGPropertyNode*) ()
#4  0x00000000011b5b30 in SGPropertyNode::eraseChild(__gnu_cxx::__normal_iterator<SGSharedPtr<SGPropertyNode>*, std::vector<SGSharedPtr<SGPropertyNode>, std::allocator<SGSharedPtr<SGPropertyNode> > > >) ()
#5  0x00000000011b5fa0 in SGPropertyNode::removeChild(char const*, int) ()
#6  0x0000000000b369c4 in f_removeChild(Context*, naRef, int, naRef*) ()
#7  0x00000000011881bf in setupFuncall ()
#8  0x0000000001189b11 in run ()
#9  0x000000000118bc78 in naCall ()
#10 0x000000000118bd86 in naCallMethodCtx ()
#11 0x0000000000fc4ce7 in boost::disable_if<boost::is_void<naRef>, naRef>::type nasal::detail::callNasalMethod<naRef>(nasal::ObjectHolder<SGReferenced> const*, nasal::Me) ()
#12 0x0000000000fc27fe in simgear::canvas::NasalWidget::onRemove() ()
#13 0x0000000000fbce29 in simgear::canvas::BoxLayout::~BoxLayout() ()
#14 0x0000000000fbde6c in simgear::canvas::VBoxLayout::~VBoxLayout() ()
#15 0x0000000000fd405c in simgear::canvas::Canvas::~Canvas() ()
#16 0x00000000011a0fee in nasal::ghostProcessDestroyList() ()
#17 0x0000000000b261d3 in FGNasalSys::update(double) ()
#18 0x00000000011f717d in SGSubsystemGroup::Member::update(double) ()
#19 0x00000000011f657b in SGSubsystemGroup::update(double) ()
#20 0x00000000011f6258 in SGSubsystemMgr::update(double) ()
#21 0x0000000000754880 in fgMainLoop() ()
#22 0x0000000000cdb56c in fgOSMainLoop() ()
#23 0x00000000007556c5 in fgMainInit(int, char**) ()
#24 0x0000000000728dea in main ()


But like I said, having a really minimal test case (Nasal snippet) to reproduce the whole thing in a self-contained fashion, ideally via the Nasal console, would be awesome.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11959
Joined: Tue Mar 25, 2008 8:40 am

Re: Segmentation fault (possibly on loading SVG file)

Postby omega95 » Sat Jul 26, 2014 7:02 pm

Here's what I got:

Code: Select all
Program received signal SIGSEGV, Segmentation fault.
0x0000000000ed9e62 in simgear::canvas::Element::getParentStyle(SGPropertyNode const*) const ()
(gdb) backtrace
#0  0x0000000000ed9e62 in simgear::canvas::Element::getParentStyle(SGPropertyNode const*) const ()
#1  0x0000000000edb84a in simgear::canvas::Element::childRemoved(SGPropertyNode*, SGPropertyNode*) ()
#2  0x00000000010e68c3 in SGPropertyNode::fireChildRemoved(SGPropertyNode*, SGPropertyNode*) ()
#3  0x00000000010e6946 in SGPropertyNode::fireChildrenRemovedRecursive() ()
#4  0x00000000010df743 in simgear::PropertyBasedMgr::childRemoved(SGPropertyNode*, SGPropertyNode*) ()
#5  0x00000000010e68c3 in SGPropertyNode::fireChildRemoved(SGPropertyNode*, SGPropertyNode*) ()
#6  0x00000000010e6946 in SGPropertyNode::fireChildrenRemovedRecursive() ()
#7  0x00000000010df743 in simgear::PropertyBasedMgr::childRemoved(SGPropertyNode*, SGPropertyNode*) ()
#8  0x00000000010e68c3 in SGPropertyNode::fireChildRemoved(SGPropertyNode*, SGPropertyNode*) ()
#9  0x00000000010e6fb2 in SGPropertyNode::eraseChild(__gnu_cxx::__normal_iterator<SGSharedPtr<SGPropertyNode>*, std::vector<SGSharedPtr<SGPropertyNode>, std::allocator<SGSharedPtr<SGPropertyNode> > > >) ()
#10 0x00000000010eb41a in SGPropertyNode::removeChildren(char const*) ()
#11 0x0000000000ae25af in f_removeChildren(Context*, naRef, int, naRef*) ()
#12 0x00000000010b82dc in run ()
#13 0x00000000010b915d in naCall ()
#14 0x00000000010b93e4 in naCallMethodCtx ()
#15 0x0000000000ad5d19 in FGNasalSys::handleCommand(char const*, char const*, char const*, SGPropertyNode const*) ()
#16 0x0000000000ad393a in FGNasalSys::handleCommand(SGPropertyNode const*) ()
#17 0x00000000010ffe1b in SGBinding::innerFire() const ()
#18 0x00000000011017c6 in fireBindingList(std::vector<SGSharedPtr<SGBinding>, std::allocator<SGSharedPtr<SGBinding> > > const&, SGPropertyNode*) ()
#19 0x0000000000f785ff in SGPickAnimation::PickCallback::buttonPressed(int, osgGA::GUIEventAdapter const&, SGPickCallback::Info const&) ()
#20 0x0000000000895646 in ActivePickCallbacks::init(int, osgGA::GUIEventAdapter const*) ()
#21 0x0000000000895dcf in FGMouseInput::doMouseClick(int, int, int, int, bool, osgGA::GUIEventAdapter const*) ()
#22 0x00000000008961c9 in mouseClickHandler(int, int, int, int, bool, osgGA::GUIEventAdapter const*) ()
#23 0x0000000000c44c9e in flightgear::FGEventHandler::handle(osgGA::GUIEventAdapter const&, osgGA::GUIActionAdapter&) ()
#24 0x00007ffff691e737 in osgViewer::Viewer::eventTraversal() ()
   from /usr/lib/libosgViewer.so.99
#25 0x00007ffff691fed9 in osgViewer::ViewerBase::frame(double) ()
   from /usr/lib/libosgViewer.so.99
#26 0x0000000000c4aafa in fgOSMainLoop() ()
#27 0x00000000006f913e in fgMainInit(int, char**) ()
#28 0x00000000006bfd36 in main ()


Ok, so I'm not able to reproduce the error every time I do this, I have to switch through the MFD pages a couple of times before I can get it to segfault.

Again, I'll see if I can try to get a nasal snippet on the console to cause this segfault.
Merlion Virtual Airlines - the experience of a flight time...
Get high quality aircraft, airports, video tutorials or development tools from my hangar.
omega95
 
Posts: 1223
Joined: Sat Jul 30, 2011 12:59 am
Location: -unknown-
Callsign: MIA0001, OM-EGA
IRC name: omega95
Version: 2.12 git
OS: Ubuntu 13.04

Re: Segmentation fault (possibly on loading SVG file)

Postby Hooray » Sat Jul 26, 2014 7:27 pm

that would be great - to help track it down and find the offending piece of code, you can use debug.bt() (for backtrace) - you just need to add it somewhere where it will be useful - doing that will probably involve wrapping call() to use it for exception handling in a try/catch fashion - e.g. using something like this:

http://wiki.flightgear.org/Exception_ha ... with_Nasal
Code: Select all
# http://plausible.org/nasal/lib.html
# call(fn, args=[], me=nil, namespace=nil, error=nil)
var try = func(function, arguments=[], object=nil, namespace=nil, catch=nil ) {
 var error = [];
 call(function, arguments, object, namespace, error);
 if (typeof(catch) == 'func' and size(error))
 catch(error);
};

var faulty = func() die("triggers a runtime error!");

try( function: faulty, catch: func(error) {
  debug.dump(error);
 debug.bt();
} );


(obviously, you can also directly use just call() - but you were asking for a try/catch equivalent a couple of days ago ...)
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11959
Joined: Tue Mar 25, 2008 8:40 am

Re: Segmentation fault (possibly on loading SVG file)

Postby TheTom » Sat Jul 26, 2014 8:18 pm

I think this is somehow timing dependent - maybe also depending on when exactly the Nasal garbage collector is running. I had some similar looking backtraces, but was able to get rid of them. But as it seems I need another round of thinking and looking at the code^^
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 10:20 am

Re: Segmentation fault (possibly on loading SVG file)

Postby Hooray » Sat Jul 26, 2014 8:42 pm

Another wild guess would be changing the type of smart pointer for styles to see if that seems to solve the problem, i.e. then we know that it's GC related ?

we could probably extend cppbind to use SG_LOG() and log deletion of Nasal/Canvas related ghosts to a file, so that we have at least /some/ way to perform a "post-crash" analysis and see if it's related to GC'ed objects or not.

if it's related to the GC removing style ghosts, that should provide at least some insight ?
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11959
Joined: Tue Mar 25, 2008 8:40 am


Return to Canvas

Who is online

Users browsing this forum: No registered users and 2 guests