sacatfhsdotse / aliquid-approxsim

0 stars 2 forks source link

Server crashes on graphs #43

Open exuvo opened 10 years ago

exuvo commented 10 years ago

$ ./bin/approxsim-server

    A P P R O X I M A T E
    -Crisis Sim

[INFO] [18:42:01] Logging started
[FATAL] [18:42:01] Listening on interface = any, port = 28444
[FATAL] [18:42:01] Engine running
Info: GLDrawableHelper.reshape: pre-exisiting GL error 0x501
[INFO] [16:44:09] Connection accepted from 127.0.0.1
*** Error in `./bin/approxsim-server': munmap_chunk(): invalid pointer: 0x00007fb056a80438 ***
======= Backtrace: =========
/usr/lib/libc.so.6(+0x73f8e)[0x7fb06bd99f8e]
/usr/lib/libc.so.6(+0x7988e)[0x7fb06bd9f88e]
./bin/approxsim-server(_ZNSt15_Sp_counted_ptrIP5GraphI8PathDataELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv+0x12)[0x609f72]
./bin/approxsim-server(_ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_releaseEv+0x1b)[0x609dcb]
./bin/approxsim-server(_ZN14ApproxsimGraphI8PathDataED0Ev+0x9)[0x609c29]
./bin/approxsim-server(_ZN19ContainerDataObjectD1Ev+0x67)[0x608c87]
./bin/approxsim-server(_ZN17ComplexDataObjectC1ERK9ReferencePKN11xercesc_3_110DOMElementE+0x16a)[0x6062ea]
./bin/approxsim-server(_ZN17DataObjectFactory16createDataObjectERK9ReferencePKN11xercesc_3_110DOMElementE+0x38a)[0x60668a]
./bin/approxsim-server(_ZN17ComplexDataObjectC1ERK9ReferencePKN11xercesc_3_110DOMElementE+0xfe)[0x60627e]
./bin/approxsim-server(_ZN17DataObjectFactory16createDataObjectERK9ReferencePKN11xercesc_3_110DOMElementE+0x38a)[0x60668a]
./bin/approxsim-server(_ZN10XMLHandler6handleERKSs+0x361)[0x6005f1]
./bin/approxsim-server(_ZN7Session22handleApproxsimMessageERKSsRSs+0x62)[0x5b1392]
./bin/approxsim-server(_ZN7Session5startEv+0x202)[0x5b3fc2]
./bin/approxsim-server(_ZN7Session11staticStartEPS_+0x9)[0x5b47b9]
./bin/approxsim-server(_ZN5boost3_bi6bind_tIvPFPvP7SessionENS0_5list1INS0_5valueIS4_EEEEEclEv+0x16)[0x5ab476]
./bin/approxsim-server[0x652bea]
/usr/lib/libpthread.so.0(+0x7124)[0x7fb06c0db124]
simonlindholm commented 10 years ago

When doing what? What does valgrind say?

exuvo commented 10 years ago

When connecting to server with scenario Afghanistan/AFGEM2.scn open. Valgrind Mismatched free() / delete / delete [] in Graph::~Graph() (Graph.h:91). Under valgrind it doesn't actually die and gives a useful error later on. Ill investigate the "Can't find type '' in.." error, might be on the scenario side.

$ 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)
simonlindholm commented 10 years ago

==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...?)

exuvo commented 10 years ago

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
exuvo commented 10 years ago

This only happens when there is at least one EffectNode in the scenario. An empty EffectGraph is fine.

exuvo commented 10 years ago

Seems to have stopped crashing, now only prints "Error: 'Can't find type '' in namespace 'http://pdc.kth.se/approxsimNamespace''" and nicely disconnects.

jesajx commented 10 years ago

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").

elegios commented 10 years ago

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

jesajx commented 10 years ago

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).

exuvo commented 10 years ago

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.