Menu

CIGI host example crashes

Jim
2012-05-11
2013-04-25
  • Jim

    Jim - 2012-05-11

    Hello

    I am having problems trying to run the examples in the CIGI Class Library on Scientific Linux 6.2 64bit and I would appreciate any assistance.

    I downloaded ccl_3_3_3.tar.gz and extracted it into /tmp. `./configure && make` had no errors so as root I installed it with `make install`. I then did a cd into /tmp/cigi/ccl/examples/CigiMiniHost and I had to resolve a few issues.

    First: `export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH` in order for pkg-config to work. I don't know why it doesn't automatically pick it up.

    Second: Build TinyXML. I used tinyxml_2_6_2.zip and extracted it into /tmp/cigi/ccl/examples/tinyxml. Inside that directory I ran `make` and then `ar rc TinyXML.a tinyxmlerror.o tinystr.o tinyxml.o tinyxmlparse.o` to create the TinyXML.a file required by CigiMiniHost makefile.

    Back in the /tmp/cigi/ccl/examples/CigiMiniHost directory I can now run make without errors.
    _____________________________________________________

    $ make
    g++ -Wall -g -D__cplusplus `pkg-config --cflags cigicl` -I../tinyxml -c MiniHost.cpp
    MiniHost.cpp: In function ‘int main(int, char**)’:
    MiniHost.cpp:241: warning: unused variable ‘sentBytes’
    g++ -Wall -g -D__cplusplus `pkg-config --cflags cigicl` -I../tinyxml -c DefaultProc.cpp
    g++ -Wall -g -D__cplusplus `pkg-config --cflags cigicl` -I../tinyxml -c SOFP.cpp
    SOFP.cpp: In member function ‘virtual void SOFP::OnPacketReceived(CigiBasePacket*)’:
    SOFP.cpp:57: warning: unused variable ‘sof’
    g++ -Wall -g -D__cplusplus `pkg-config --cflags cigicl` -I../tinyxml -c AnimStop.cpp
    g++ -Wall -g -D__cplusplus `pkg-config --cflags cigicl` -I../tinyxml -c Network.cpp
    g++ \
        -o CigiMiniHost \
        MiniHost.o DefaultProc.o SOFP.o AnimStop.o Network.o \
        ../tinyxml/TinyXML.a -lm -lpthread \
        `pkg-config --libs cigicl`
    

    _____________________________________________________

    An `ls` shows CigiMiniHost. Great! Until I try to run it that is…
    _____________________________________________________

    $./CigiMiniHost 
    *** glibc detected *** ./CigiMiniHost: free(): invalid pointer: 0x000000000061b978 ***
    ======= Backtrace: =========
    /lib64/libc.so.6[0x3f14075296]
    /usr/lib64/libstdc++.so.6(_ZNSsD1Ev+0x39)[0x3f1d89d4c9]
    ./CigiMiniHost[0x403382]
    ./CigiMiniHost[0x402ef1]
    ./CigiMiniHost[0x402675]
    /lib64/libc.so.6(__libc_start_main+0xfd)[0x3f1401ecdd]
    ./CigiMiniHost[0x402599]
    ======= Memory map: ========
    00400000-00413000 r-xp 00000000 08:01 3050                               /tmp/cigi/ccl/examples/CigiMiniHost/CigiMiniHost
    00613000-00614000 rw-p 00013000 08:01 3050                               /tmp/cigi/ccl/examples/CigiMiniHost/CigiMiniHost
    00614000-0061c000 rw-p 00000000 00:00 0 
    02251000-02272000 rw-p 00000000 00:00 0                                  [heap]
    3f13800000-3f13820000 r-xp 00000000 08:01 794343                         /lib64/ld-2.12.so
    3f13a1f000-3f13a20000 r--p 0001f000 08:01 794343                         /lib64/ld-2.12.so
    3f13a20000-3f13a21000 rw-p 00020000 08:01 794343                         /lib64/ld-2.12.so
    3f13a21000-3f13a22000 rw-p 00000000 00:00 0 
    3f14000000-3f14186000 r-xp 00000000 08:01 794344                         /lib64/libc-2.12.so
    3f14186000-3f14386000 ---p 00186000 08:01 794344                         /lib64/libc-2.12.so
    3f14386000-3f1438a000 r--p 00186000 08:01 794344                         /lib64/libc-2.12.so
    3f1438a000-3f1438b000 rw-p 0018a000 08:01 794344                         /lib64/libc-2.12.so
    3f1438b000-3f14390000 rw-p 00000000 00:00 0 
    3f14400000-3f14417000 r-xp 00000000 08:01 794352                         /lib64/libpthread-2.12.so
    3f14417000-3f14616000 ---p 00017000 08:01 794352                         /lib64/libpthread-2.12.so
    3f14616000-3f14617000 r--p 00016000 08:01 794352                         /lib64/libpthread-2.12.so
    3f14617000-3f14618000 rw-p 00017000 08:01 794352                         /lib64/libpthread-2.12.so
    3f14618000-3f1461c000 rw-p 00000000 00:00 0 
    3f14800000-3f14883000 r-xp 00000000 08:01 794367                         /lib64/libm-2.12.so
    3f14883000-3f14a82000 ---p 00083000 08:01 794367                         /lib64/libm-2.12.so
    3f14a82000-3f14a83000 r--p 00082000 08:01 794367                         /lib64/libm-2.12.so
    3f14a83000-3f14a84000 rw-p 00083000 08:01 794367                         /lib64/libm-2.12.so
    3f19400000-3f19416000 r-xp 00000000 08:01 794372                         /lib64/libgcc_s-4.4.6-20110824.so.1
    3f19416000-3f19615000 ---p 00016000 08:01 794372                         /lib64/libgcc_s-4.4.6-20110824.so.1
    3f19615000-3f19616000 rw-p 00015000 08:01 794372                         /lib64/libgcc_s-4.4.6-20110824.so.1
    3f1d800000-3f1d8e8000 r-xp 00000000 08:01 159808                         /usr/lib64/libstdc++.so.6.0.13
    3f1d8e8000-3f1dae8000 ---p 000e8000 08:01 159808                         /usr/lib64/libstdc++.so.6.0.13
    3f1dae8000-3f1daef000 r--p 000e8000 08:01 159808                         /usr/lib64/libstdc++.so.6.0.13
    3f1daef000-3f1daf1000 rw-p 000ef000 08:01 159808                         /usr/lib64/libstdc++.so.6.0.13
    3f1daf1000-3f1db06000 rw-p 00000000 00:00 0 
    7f2073a9d000-7f2073aa2000 rw-p 00000000 00:00 0 
    7f2073aa2000-7f2073b48000 r-xp 00000000 08:01 1185175                    /usr/local/SubrScene.12X/lib/libcigicl.so.0.0.0
    7f2073b48000-7f2073d47000 ---p 000a6000 08:01 1185175                    /usr/local/SubrScene.12X/lib/libcigicl.so.0.0.0
    7f2073d47000-7f2073d4d000 rw-p 000a5000 08:01 1185175                    /usr/local/SubrScene.12X/lib/libcigicl.so.0.0.0
    7f2073d4d000-7f2073d4e000 rw-p 00000000 00:00 0 
    7f2073d61000-7f2073d63000 rw-p 00000000 00:00 0 
    7fff1eac2000-7fff1ead7000 rw-p 00000000 00:00 0                          [stack]
    7fff1ebff000-7fff1ec00000 r-xp 00000000 00:00 0                          [vdso]
    ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
    Aborted
    

    _____________________________________________________

    We have attempted to debug this with gdb - it seems to be crashing when the call to ReadConfig() returns in the main() program (in MiniHost.cpp).  Just before it crashes, the debugger has us inside tinyxml.h on a call to ~TiXmlDocument() (line 1409).  The exact same thing happens when we try to run DummyIG.  So far, we can't figure out what is wrong. I was hoping maybe someone here could help us out.

    Thanks!

     
  • Andrew Sampson

    Andrew Sampson - 2012-05-18

    I followed the process you've described, building TinyXML.a in the same manner, from the same version of TinyXML (2.6.2).  I experienced the same crasher.

    I repeated the process with an older TinyXML (2.4.2), which was compiled differently (built as a .so instead of statically, and with different options).  The crash did not manifest.

    To eliminate linking weirdness as the culprit, I built everything into one binary, skipping the TinyXML.a step.  This also gained me debug symbols in tinyxml.

    g++ -Wall -g -D__cplusplus `pkg-config --cflags cigicl ` -I../tinyxml  *.cpp ../tinyxml/{tinystr.cpp,tinyxml.cpp,tinyxmlerror.cpp,tinyxmlparser.cpp} -o CigiMiniHost-builtAllInOneWithNewTinyXML `pkg-config --libs cigicl ` -lm -lpthread
    

    Crashing again.  Valgrind now reveals that it's dying while trying to delete some std::strings.  Looking at the code reveals that MiniHost.cpp is defining TINYXML_USE_STL and TIXML_USE_STL, yet tinyxml was *not* built with these options enabled.

    Recompiling with these options forced via the compiler command line:

    g++ -Wall -g -D__cplusplus -DTINYXML_USE_STL -DTIXML_USE_STL `pkg-config --cflags cigicl ` -I../tinyxml  *.cpp ../tinyxml/{tinystr.cpp,tinyxml.cpp,tinyxmlerror.cpp,tinyxmlparser.cpp} -o CigiMiniHost-builtAllInOneWithNewTinyXML `pkg-config --libs cigicl ` -lm -lpthread
    

    …produces a binary that actually works.

    In summary, tinyxml is being built without TINYXML_USE_STL/TIXML_USE_STL, but MiniHost.cpp is setting those options anyway. 

    You're not the first to have problems with tinyxml and the ccl examples.  XML is totally overkill for parsing a config file containing 7 variables, so we should probably switch to a simpler config format and manually parsing it.

     

Log in to post a comment.