The problem is that csBlockAllocator calls destructors of the
objects it contains. I don't know when this would ever be necessary,
but in the case of an XML document node tree where the root node 'leaks'
during program execution, the blockallocator enters a loop calling the
destructor on each valid object it contains. The first object it
destructs is the root node, which happens to destruct all other nodes,
but the blockallocator is already in its' destruction loop, so after the
root node (and all other nodes) are fully destructed, it proceeds on to
try and destruct each node again, causing a crash.
In my opinion the block allocator should stick to its' job as a heap
management layer, and leave the object lifecycle management to the code
above it.
Andrew/Rhad
Peter Amstutz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Crystal Space on amd64 Linux, compiled with
> - --enable-shared, --enable-debug and --disable-ptmalloc
>
> I'm getting the following crash on exit in my program. I recall from
> diagnosing a similar error in csKDTree that certain static variables need
> to be destroyed in a specific order when one static variable type refers
> to another (otherwise you get double-free crashes). Could that be
> happening here?
>
> (gdb) bt
> #0 0x000000000083fe80 in ?? ()
> #1 0x00002aaab3bd79ec in ~csRef (this=0x83c538) at ref.h:184
> #2 0x00002aaab3bdce04 in ~WrappedChild (this=0x83c538) at docwrap.h:114
> #3 0x00002aaab3bdce2b in
> csBlockAllocator<CS::Plugin::XMLShader::csWrappedDocumentNode::WrappedChild,
> CS::Memory::AllocatorMalloc>::DestroyObject (
> this=0x7d74d0, p=0x83c538, warn=false, invokeDtor=true)
> at blockallocator.h:155
> #4 0x00002aaab3bdd033 in
> csBlockAllocator<CS::Plugin::XMLShader::csWrappedDocumentNode::WrappedChild,
> CS::Memory::AllocatorMalloc>::DisposeAll (
> this=0x7d74d0, warn_unfreed=false) at blockallocator.h:200
> #5 0x00002aaab3bdd0c6 in ~csBlockAllocator (this=0x7d74d0)
> at blockallocator.h:269
> #6 0x00002aaab3bd4ceb in
> CS::Plugin::XMLShader::csWrappedDocumentNode::WrappedChild::ChildAlloc_kill
> ()
> at
> plugins/video/render3d/shader/shadercompiler/xmlshader/docwrap.cpp:349
> #7 0x00002aaab3c0ca28 in csStaticVarCleanup_local (p=0)
> at
> plugins/video/render3d/shader/shadercompiler/xmlshader/xmlshader.cpp:37
> #8 0x00002aaab3c0cab6 in csXMLShaderCompiler_scfFinalize ()
> at
> plugins/video/render3d/shader/shadercompiler/xmlshader/xmlshader.cpp:46
> #9 0x00002aaaaada39fd in ~scfSharedLibrary (this=0x55db50)
> at libs/csutil/scf.cpp:273
> #10 0x00002aaaaada8126 in
> csPDelArrayElementHandler<scfSharedLibrary*>::Destroy
> (address=0x11ffab8) at parray.h:47
> #11 0x00002aaaaadaa12f in csArray<scfSharedLibrary*,
> csPDelArrayElementHandler<scfSharedLibrary*>, CS::Memory::AllocatorMalloc,
> csArrayCapacityDefault>::DeleteIndex (this=0x5129d0, n=15) at array.h:1046
> #12 0x00002aaaaadaa1b8 in scfSharedLibrary::TryUnload (this=0x55db50)
> at libs/csutil/scf.cpp:222
> #13 0x00002aaaaada59ca in csSCF::UnloadUnusedModules (this=0x512280)
> at libs/csutil/scf.cpp:924
> #14 0x00002aaaaada5a41 in ~csSCF (this=0x512280) at
> libs/csutil/scf.cpp:765
> #15 0x00002aaaaada44fd in csSCF::Finish (this=0x512280)
> at libs/csutil/scf.cpp:884
> #16 0x00002aaaaae9073d in csInitializer::DestroyApplication (r=0x5727d8)
> at libs/cstool/initapp.cpp:500
> #17 0x0000000000404c4c in main (argc=<value optimized out>,
> argv=<value optimized out>) at csplugintest.cc:346
>
>
> [ Peter Amstutz ][ [EMAIL PROTECTED] ][ [EMAIL PROTECTED] ]
> [Lead Programmer][Interreality Project][Virtual Reality for the Internet]
> [ VOS: Next Generation Internet Communication][ http://interreality.org ]
> [ http://interreality.org/~tetron ][ pgpkey: pgpkeys.mit.edu 18C21DF7 ]
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
>
> iD4DBQFEncbwaeHUyhjCHfcRAnQHAJdF7/bXRX1ScJzrNbzUMymugjIXAKCSUQOh
> UprK2ZRggFc5WefmnLwfGQ==
> =nuRj
> -----END PGP SIGNATURE-----
>
>
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Crystal-main mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/crystal-main
> Unsubscribe: mailto:[EMAIL PROTECTED]
>
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Crystal-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]