Hi all,

I am not sure, but maybe we have the cause for the segfaults/failed assert (big thanks at Joacim for finding the point).

The _effectTexture is "loaded" by ssgTexture* ssgLoaderOptions::createTexture. If the texture is already loaded, a pointer to this texture is returned. But SGShaderAnimation::~SGShaderAnimation() does not check, if the texture is used by another object, it just deletes it without checking the refcount of the texture or deleting it from the list, createTexture is using. If then a multiplayer connects with an aircraft using the same texture, createTexture returns the pointer to this already deleted texture and flightgear crahses.

The enclosed patch removes the deltete _effectTexture form the destructor. (Didn't find out, how to reduce the refcount and delete it, if refcount is zero and remove it from the list createTexture is using).

I think we should commit this to plib and head.

Maik



Joacim Persson schrieb am 24.01.2007 18:05:
On Fri, 5 Jan 2007, Maik Justus wrote:

Hello,

sometimes I get a segfault in function SGShaderAnimation::~SGShaderAnimation(), file simgear/scene/model/shadanim.cxx.

I never get a SIGSEGV from there, but rather a SIGABORT due to a failed
assert. (This with plib, nota bene) And from the gang-debugging session we
had last night on IRC+MP we now know how to replicate it. (although I'm not
sure if there was a consesus on exactly how, but something like this: at least
two models using the chrome shader, one leaves mp and then fgfs crashes for
any miserable one watching them leave. Other's said it was provoked by a
join-leave-rejoin cycle)

I looked through my gdb logs frm last night again now and found this
interesting little piece of forensic evidence:
#############################
$30 = {<SGAnimation> = {<ssgBase> = {_vptr.ssgBase = 0x861cd08, refc = 0, 
unique = 169256, type = 1,
       spare = 0, name = 0x0, user_data = 0x0}, static current_object = 0x0,
     static sim_time_sec = 370.01666666663874, _branch = 0xe84da10, 
animation_type = 0}, _condition = 0x0,
   _condition_value = true, _shader_type = 3, _param_1 = 1, _param_color = 
{9.52882956e-44, 9.38869971e-44,
     9.52882956e-44, 8.82818033e-44}, _depth_test = true, _factor = 1, 
_factor_prop = {_ptr = 0x0},
   _speed = 1, _speed_prop = {_ptr = 0x0}, _effectTexture = 0xe822df8,
   _textureData = 0xe860b98 
"\216\211\214\210\203\207\203~\201{wzxtvwtvwtuwtuxuvyvwywwzwx~}{\200\200~\201\202\1
77\202\203\177\202\203\177\211\204\206\201\177|\205\205\204\206\206\206\206\206\206\206\206\206\223\224\222\23
0\231\226\232\234\231\234\236\232\235\237\233\235\237\233\236\237\234\236| 
\234\236| \234\236| \234\236| \234\
236| \234\236| 
\234\236\237\234\235\237\233\235\237\233\234\236\232\232\234\231\230\231\226\223\224\222\206\20
6\206\206\206\206\206\206\206\205\205\204\201\177|\211\204\206\202\203\177\202\203\177\201\202\177\200\200~~}{
zwxywwyvwxuvwtuwtuwtvxtv{wz\203~\201\210\204\207\203~\201{w"..., _texWidth = 
64, _texHeight = 64, _envColor =
{
     0.853901267, 0.865621746, 0.934002459, 1}}
(gdb) print * this._effectTexture
$31 = {<ssgBase> = {_vptr.ssgBase = 0x862d428, refc = 1, unique = 169252, type 
= 17, spare = 0, name = 0x0,
     user_data = 0x0}, filename = 0x0, own_handle = 0, handle = 0, wrapu = 0, 
wrapv = 0, mipmap = 0,
   has_alpha = false}
###############################

Note the refc's are different for the parent and child.


Something like this perhaps?
  if (_effectTexture->getRef()==UNUSED) delete _effectTexture;
#define UNUSED 0 // ??





-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Index: shadanim.cxx
===================================================================
RCS file: /var/cvs/SimGear-0.3/source/simgear/scene/model/shadanim.cxx,v
retrieving revision 1.7
diff -u -p -r1.7 shadanim.cxx
--- shadanim.cxx        1 Jul 2006 20:06:05 -0000       1.7
+++ shadanim.cxx        25 Jan 2007 21:33:24 -0000
@@ -618,7 +618,7 @@ void SGShaderAnimation::init()
 SGShaderAnimation::~SGShaderAnimation()
 {
     delete _condition;
-    delete _effectTexture;
+    //delete _effectTexture;
     delete _textureData;
 }
 
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to