Open exuvo opened 10 years ago
When doing what? What does valgrind say?
When connecting to server with scenario Afghanistan/AFGEM2.scn open.
Valgrind Mismatched free() / delete / delete [] in Graph
$ valgrind bin/approxsim-server
==30409== Memcheck, a memory error detector
==30409== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==30409== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==30409== Command: bin/approxsim-server
==30409==
A P P R O X I M A T E
-Crisis Sim
[INFO] [21:32:20] Logging started
[FATAL] [21:32:20] Listening on interface = any, port = 28444
[FATAL] [21:32:20] Engine running
[INFO] [19:32:26] Connection accepted from 127.0.0.1
==30409== Thread 5:
==30409== Mismatched free() / delete / delete []
==30409== at 0x4C29E6C: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==30409== by 0x609F01: Graph<PathData>::~Graph() (Graph.h:91)
==30409== by 0x609F71: std::_Sp_counted_ptr<Graph<PathData>*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() (shared_ptr_base.h:373)
==30409== by 0x609DCA: std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (shared_ptr_base.h:149)
==30409== by 0x609C28: ApproxsimGraph<PathData>::~ApproxsimGraph() (DataObjectImpl.h:476)
==30409== by 0x608C86: ContainerDataObject::~ContainerDataObject() (DataObjectImpl.cpp:303)
==30409== by 0x6062E9: ComplexDataObject::ComplexDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:456)
==30409== by 0x606689: DataObjectFactory::createDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:1004)
==30409== by 0x60627D: ComplexDataObject::ComplexDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:452)
==30409== by 0x606689: DataObjectFactory::createDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:1004)
==30409== by 0x6005F0: XMLHandler::handle(std::string const&) (XMLHandler.cpp:225)
==30409== by 0x5B1391: Session::handleApproxsimMessage(std::string const&, std::string&) (Session.cpp:103)
==30409== Address 0x1631bb90 is 0 bytes inside a block of size 128 alloc'd
==30409== at 0x4C293B0: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==30409== by 0x5F99AD: Graph<PathData>* XMLHelper::getGraph<PathData>(xercesc_3_1::DOMElement const&, Reference const&) (XMLHelper.cpp:845)
==30409== by 0x609544: ApproxsimGraph<PathData>::ApproxsimGraph(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:938)
==30409== by 0x60662C: DataObjectFactory::createDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:998)
==30409== by 0x60627D: ComplexDataObject::ComplexDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:452)
==30409== by 0x606689: DataObjectFactory::createDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:1004)
==30409== by 0x60627D: ComplexDataObject::ComplexDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:452)
==30409== by 0x606689: DataObjectFactory::createDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:1004)
==30409== by 0x6005F0: XMLHandler::handle(std::string const&) (XMLHandler.cpp:225)
==30409== by 0x5B1391: Session::handleApproxsimMessage(std::string const&, std::string&) (Session.cpp:103)
==30409== by 0x5B3FC1: Session::start() (Session.cpp:348)
==30409== by 0x5B47B8: Session::staticStart(Session*) (Session.cpp:395)
==30409==
==30409== Invalid free() / delete / delete[] / realloc()
==30409== at 0x4C29E6C: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==30409== by 0x609F71: std::_Sp_counted_ptr<Graph<PathData>*, (__gnu_cxx::_Lock_policy)2>::_M_dispose() (shared_ptr_base.h:373)
==30409== by 0x609DCA: std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (shared_ptr_base.h:149)
==30409== by 0x609C28: ApproxsimGraph<PathData>::~ApproxsimGraph() (DataObjectImpl.h:476)
==30409== by 0x608C86: ContainerDataObject::~ContainerDataObject() (DataObjectImpl.cpp:303)
==30409== by 0x6062E9: ComplexDataObject::ComplexDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:456)
==30409== by 0x606689: DataObjectFactory::createDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:1004)
==30409== by 0x60627D: ComplexDataObject::ComplexDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:452)
==30409== by 0x606689: DataObjectFactory::createDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:1004)
==30409== by 0x6005F0: XMLHandler::handle(std::string const&) (XMLHandler.cpp:225)
==30409== by 0x5B1391: Session::handleApproxsimMessage(std::string const&, std::string&) (Session.cpp:103)
==30409== by 0x5B3FC1: Session::start() (Session.cpp:348)
==30409== Address 0xeb46378 is 8 bytes inside a block of size 104 alloc'd
==30409== at 0x4C293B0: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==30409== by 0x5F9817: Graph<PathData>* XMLHelper::getGraph<PathData>(xercesc_3_1::DOMElement const&, Reference const&) (XMLHelper.cpp:826)
==30409== by 0x609544: ApproxsimGraph<PathData>::ApproxsimGraph(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:938)
==30409== by 0x60662C: DataObjectFactory::createDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:998)
==30409== by 0x60627D: ComplexDataObject::ComplexDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:452)
==30409== by 0x606689: DataObjectFactory::createDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:1004)
==30409== by 0x60627D: ComplexDataObject::ComplexDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:452)
==30409== by 0x606689: DataObjectFactory::createDataObject(Reference const&, xercesc_3_1::DOMElement const*) (DataObjectImpl.cpp:1004)
==30409== by 0x6005F0: XMLHandler::handle(std::string const&) (XMLHandler.cpp:225)
==30409== by 0x5B1391: Session::handleApproxsimMessage(std::string const&, std::string&) (Session.cpp:103)
==30409== by 0x5B3FC1: Session::start() (Session.cpp:348)
==30409== by 0x5B47B8: Session::staticStart(Session*) (Session.cpp:395)
==30409==
[ERROR] [19:33:11] /home/exuvo/code/c/approxim/server/src/Network/Session.cpp:288:handleApproxsimMessage Session 1 caught Error: 'Can't find type '' in namespace 'http://pdc.kth.se/approxsimNamespace''
[INFO] [19:33:11] Connection closed by client
Closing Session.
[INFO] [19:33:11] Session with id 1 run by thread ending
^C==30409==
==30409== HEAP SUMMARY:
==30409== in use at exit: 2,784,885 bytes in 43,493 blocks
==30409== total heap usage: 975,179 allocs, 931,687 frees, 298,496,761 bytes allocated
==30409==
==30409== LEAK SUMMARY:
==30409== definitely lost: 240 bytes in 3 blocks
==30409== indirectly lost: 0 bytes in 0 blocks
==30409== possibly lost: 1,786,360 bytes in 24,995 blocks
==30409== still reachable: 998,285 bytes in 18,495 blocks
==30409== suppressed: 0 bytes in 0 blocks
==30409== Rerun with --leak-check=full to see details of leaked memory
==30409==
==30409== For counts of detected and suppressed errors, rerun with: -v
==30409== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 1 from 1)
==30409== Mismatched free() / delete / delete []
känns som en false positive, men bör definitivt fixas. ~Graph ska göra delete[], inte delete, på båda ställena.
savedGraphs-saken känns trasig, den borde göra en djup kopia utav grafen, eller så borde man inte delete:a saker från destrukturn alls (om de är menade att leva kvar för evigt). (Varför sparar vi ens grafer för evigt...?)
gdb på krash utan valgrind:
(gdb) bt
#0 0x00007ffff6239d67 in raise () from /usr/lib/libc.so.6
#1 0x00007ffff623b118 in abort () from /usr/lib/libc.so.6
#2 0x00007ffff6279f93 in __libc_message () from /usr/lib/libc.so.6
#3 0x00007ffff627f88e in malloc_printerr () from /usr/lib/libc.so.6
#4 0x000000000060a652 in std::_Sp_counted_ptr<Graph<PathData>*, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=<optimized out>)
at /usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/bits/shared_ptr_base.h:373
#5 0x000000000060a4ab in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x7fffdea56e70)
at /usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/bits/shared_ptr_base.h:149
#6 0x000000000060a309 in ApproxsimGraph<PathData>::~ApproxsimGraph (
this=0x7fffdea806c0)
at /home/exuvo/code/c/approxim/server/src/Taclan/DataObjectImpl.h:476
#7 0x0000000000609367 in ContainerDataObject::~ContainerDataObject (
this=0x7fffe8054a00)
at /home/exuvo/code/c/approxim/server/src/Taclan/DataObjectImpl.cpp:303
#8 0x00000000006069ca in ComplexDataObject::ComplexDataObject (
this=0x7fffe8054a00, scope=..., n=<optimized out>)
at /home/exuvo/code/c/approxim/server/src/Taclan/DataObjectImpl.cpp:456
#9 0x0000000000606d6a in DataObjectFactory::createDataObject (scope=...,
n=0x7fffe8004c90)
at /home/exuvo/code/c/approxim/server/src/Taclan/DataObjectImpl.cpp:1004
#10 0x000000000060695e in ComplexDataObject::ComplexDataObject (
this=0x7fffe8095dc0, scope=..., n=0x7fffe8003438)
at /home/exuvo/code/c/approxim/server/src/Taclan/DataObjectImpl.cpp:452
#11 0x0000000000606d6a in DataObjectFactory::createDataObject (scope=...,
n=0x7fffe8003438)
at /home/exuvo/code/c/approxim/server/src/Taclan/DataObjectImpl.cpp:1004
#12 0x0000000000600cd1 in XMLHandler::handle (this=0x7fffe40009b0, xml=...)
at /home/exuvo/code/c/approxim/server/src/Taclan/XMLHandler.cpp:225
#13 0x00000000005b1512 in Session::handleApproxsimMessage (this=0x7fffe4000cb0,
xml=..., response=...)
at /home/exuvo/code/c/approxim/server/src/Network/Session.cpp:103
#14 0x00000000005b43d2 in Session::start (this=0x7fffe4000cb0)
at /home/exuvo/code/c/approxim/server/src/Network/Session.cpp:356
#15 0x00000000005b4bc9 in Session::staticStart (instance=0x7fffe4000cb0)
at /home/exuvo/code/c/approxim/server/src/Network/Session.cpp:403
#16 0x00000000005ab5f6 in boost::_bi::bind_t<void, void* (*)(Session*), boost::_bi::list1<boost::_bi::value<Session*> > >::operator() (this=0x0)
at /usr/include/boost/bind/bind_template.hpp:20
This only happens when there is at least one EffectNode in the scenario. An empty EffectGraph is fine.
Seems to have stopped crashing, now only prints "Error: 'Can't find type '' in namespace 'http://pdc.kth.se/approxsimNamespace''" and nicely disconnects.
The type-thing was because the server tried to read the EffectGraph into a ComplexDataObject, which leads to it trying to do the same for Points (and it can't figure out the types for lon and lat elements). Fixed in 384e4172021e5b8bf8928287c63e7864f3bdd886.
New problem: servergraphs thinks effectnodes contain the same elements as effectedges (added Error: "No 'connected' tag in element nodes").
That second problem happens to be intended. Edges and nodes in an effectgraph both have a connected effect and a disconnected effect, both of which are optional.
— /Viktor
On Fri, May 9, 2014 at 9:02 PM, jesajx notifications@github.com wrote:
The type-thing was because the server tried to read the EffectGraph into a ComplexDataObject, which leads to it trying to the same for Points (and it can't figure out the lon and lat elements). Fixed in 384e4172021e5b8bf8928287c63e7864f3bdd886.
New problem: servergraphs thinks effectnodes contain the same elements as effectedges.
Reply to this email directly or view it on GitHub: https://github.com/sootn/aliquid-approxsim/issues/43#issuecomment-42701789
Ok, sry. Jumped to conclusions due to only looking in the .scn (and not the .xsd).
But the problem remains. The effects are optional for nodes:
<xsd:complexType name="EffectNode">
...
<xsd:element name="power" type="sp:Double"/>
<xsd:element name="connected" type="sp:Effect" minOccurs="0"/>
<xsd:element name="disconnected" type="sp:Effect" minOccurs="0"/>
...
</xsd:complexType>
<xsd:complexType name="EffectEdge">
...
<xsd:element name="connected" type="sp:Effect"/>
<xsd:element name="disconnected " type="sp:Effect"/>
...
</xsd:complexType>
We should make them optional in both or mandatory in both, otherwise the server will force the nodes to have effects (like it is now) or allow edges to not have effects (which would be a problem).
I think optional effects is the best solution, otherwise you need to set the effect radius to 0 every time you don't want an effect.
$ ./bin/approxsim-server