Start of any flightgear program caushes immediate segfault. I have debugged this, and want to make sure it is not a known problem.
Slackware 14.2 Linux 4.4.38, 4.4.88 and 4.4.153.
GCC 5.3.0 and 5.5.0.
In SimGear there is a SSScaleTransform that is derived from osg::Transform.
I have created several test objects to verify that any object derived from osg::Transform will segfault during the constructor of osg::Transform.
I built SimGear with debugging so I could follow it.
Other similar objects I made did not segfault.
A simple object with only two fields derived from osg::Transform, will also segfault in the constructor.
(Edit: Latest tests show that the segfault occurs in the SGVec3 constructor <template> which is a field in the same object.
My initial test objects were including the SGVec3 as the two fields.
One of the latest test objects derives from osg:::Transform without including the SGVec3 field and it does not segfault.
This test code is in a later post.)
This happens for OpenSceneGraph 3.4.0 and 3.5.5.
Currently I am trying to build Flightgear 2018.2.2, but have had build problems for every recent version of flightgear. I have not had a flightgear build since I had Linux 2.6.
It seems that it will segfault if the SGScaleTransform constructor is called from "new" but not if it is a static variable.
My most immediate solution is to modify the WrapperProxy, take out the "new" and make SGScaleTransform a static variable.
At least it does not segfault immediately.
This could be happening for several reasons:
1. There is a field in SGScaleTransform that is not initialized right away, and the constructor of osg:Transform is indirectly invoking a virtual function that leads to a SGScaleTransform function running and trying to use garbage values as a ptr. The garbage values on my system just happen to be more fatal than the garbage values on your system.
2. The osg::Transform is indirectly accessing some other structure that is not setup up yet, but it assumes that it is setup already.
3. The virtual setup on my GCC 5.5.0 compiler is different enough that some indirectly invoked virtual function calls in the osg::Transform is access the virtual call system before it is
able to handle them. Any virtual call during a constructor is capable of going wrong due to the strange setup rules for the virtual tables during constructors.
A properly written object should be careful to never call a virtual function during a constructor, not even indirectly. I suspect there is such a call in OpenSceneGraph.
There have been other postings about OpenSceneGraph segfaulting when some calls are done in the wrong order, so I think this is worthy of being made less fragile.
Is this some known and fixed in the next release (I doubt that, it been there for so many releases now) ?
Can you get OpenSceneGraph to fix their constructor to not call any virtuals ??
As I said previously, you might not get these segfaults just because your garbage values are not as fatal as the garbage values on my system.
It should not be accessing the garbage values in the first place.