mGGk-fr / ghostplusplus

GOOGLE CODE BACKUP : Bot for mananging W3 Matches
Other
0 stars 0 forks source link

Segfault when using -O2 or -O3 but not with -O0 with gcc 4.7.0 #130

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile Ghost++ with gcc 4.7.0, using flags -O2 or -O3
2. Run Ghost++

What is the expected output? What do you see instead?

It was expected to run just fine, but it crashes. 
I compiled it with -g to better check it and it stops crashing. (yay!)

When I enabled -O2 with -g I got this output:

[GHOST] finished loading [ip-to-country.csv]
[GHOST] GHost++ Version 17.1 (with MySQL support)
[BNET: server.eurobattle.net] connecting to server [server.eurobattle.net] on 
port 6112
[BNET: server.eurobattle.net] resolved and cached server IP address 
188.165.23.200
[BNET: server.eurobattle.net] connected

Program received signal SIGSEGV, Segmentation fault.
0x00000000004095cd in __exchange_and_add (__mem=0x7c9bfca9, __val=<optimized 
out>)
    at /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ext/atomicity.h:48
48        { return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
(gdb) bt
#0  0x00000000004095cd in __exchange_and_add (__mem=0x7c9bfca9, 
__val=<optimized out>)
    at /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ext/atomicity.h:48
#1  __gnu_cxx::__exchange_and_add_dispatch (__mem=__mem@entry=0x7c9bfca9, 
__val=-1)
    at /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ext/atomicity.h:81
#2  0x000000000040d23c in _M_dispose (__a=..., this=0x7c9bfc99)
    at /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/basic_string.h:242
#3  ~basic_string (this=0x7fffffffccf0, __in_chrg=<optimized out>)
    at /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/basic_string.h:536
#4  CBNCSUtilInterface::HELP_SID_AUTH_CHECK (this=<optimized out>, TFT=true, 
war3Path=..., keyROC='F' <repeats 26 times>, keyTFT=
    'F' <repeats 26 times>, valueStringFormula=..., mpqFileName="IX86ver1.mpq", clientToken=std::vector of length 4, capacity 4 = {...},
    serverToken=std::vector of length 4, capacity 4 = {...}) at bncsutilinterface.cpp:106
#5  0x0000000000420073 in CBNET::ProcessPackets (this=this@entry=0x7f66d0) at 
bnet.cpp:761
#6  0x00000000004253ec in CBNET::Update (this=0x7f66d0, fd=0x7fffffffe4f0, 
send_fd=0x7fffffffe570) at bnet.cpp:488
#7  0x000000000048ed36 in CGHost::Update (this=this@entry=0x7c07d0, 
usecBlock=49920, usecBlock@entry=50000) at ghost.cpp:989
#8  0x000000000040b914 in main (argc=<optimized out>, argv=<optimized out>) at 
ghost.cpp:358
(gdb) frame 4
#4  CBNCSUtilInterface::HELP_SID_AUTH_CHECK (this=<optimized out>, TFT=true, 
war3Path=..., keyROC='F' <repeats 26 times>, keyTFT=
    'F' <repeats 26 times>, valueStringFormula=..., mpqFileName="IX86ver1.mpq", clientToken=std::vector of length 4, capacity 4 = {...},
    serverToken=std::vector of length 4, capacity 4 = {...}) at bncsutilinterface.cpp:106
106             return false;

What version of the product are you using? On what operating system?

I'm on arch linux with gcc 4.7.0

Please provide any additional information below.

Original issue reported on code.google.com by wuer...@gmail.com on 22 May 2012 at 1:12

GoogleCodeExporter commented 9 years ago
Confirm this.
Nearly the same output from gdb. I have modified ghost++ sources, so lines may 
differ a bit.
Environment: Kernel 3.6.11-gentoo, boost 1.52, GCC 4.7.3
Thanks for pointing about disabling optimization flags.

Program received signal SIGSEGV, Segmentation fault.
0x00000000004124fd in __exchange_and_add (__mem=0x7c9bfca9,
    __val=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include/g++-v4/ext/atomicity.h:48
48        { return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
(gdb) bt
#0  0x00000000004124fd in __exchange_and_add (__mem=0x7c9bfca9,
    __val=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include/g++-v4/ext/atomicity.h:48
#1  __gnu_cxx::__exchange_and_add_dispatch (__mem=__mem@entry=0x7c9bfca9,
    __val=-1)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include/g++-v4/ext/atomicity.h:81
#2  0x000000000041b0e1 in _M_dispose (__a=..., this=0x7c9bfc99)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include/g++-v4/bits/basic_string.h:242
#3  ~basic_string (this=0x7fffffffbdf0, __in_chrg=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/include/g++-v4/bits/basic_string.h:536
#4  CBNCSUtilInterface::HELP_SID_AUTH_CHECK (this=0x8731c0, TFT=true,
    war3Path=..., keyROC='F' <repeats 26 times>, keyTFT=
    'F' <repeats 26 times>, valueStringFormula=
    "A=3845581634 B=880823580 C=1363937103 4 A=A-S B=B-C C=C-A A=A-B",
    mpqFileName="IX86ver1.mpq",
    clientToken=std::vector of length 4, capacity 4 = {...},
    serverToken=std::vector of length 4, capacity 4 = {...})
    at bncsutilinterface.cpp:118
#5  0x000000000042a841 in CBNET::ProcessPackets (this=this@entry=0x872d90)
    at bnet.cpp:760
#6  0x000000000042f5ec in CBNET::Update (this=0x872d90, fd=0x7fffffffd840,
---Type <return> to continue, or q <return> to quit---
    send_fd=0x7fffffffd8c0) at bnet.cpp:487
#7  0x000000000048aab7 in CGHost::Update (this=0x8351e0,
    usecBlock=<optimized out>, usecBlock@entry=50000) at ghost.cpp:1223
#8  0x00000000004186e1 in main (argc=<optimized out>, argv=<optimized out>)
    at ghost.cpp:399

Original comment by masterpe...@gmail.com on 28 Nov 2013 at 5:11

GoogleCodeExporter commented 9 years ago
Works fine with GCC 4.6.3, -O3 flag set

Original comment by masterpe...@gmail.com on 28 Nov 2013 at 5:25

GoogleCodeExporter commented 9 years ago
this issue https://code.google.com/p/ghostplusplus/issues/detail?id=136 
provides a fix, which works with gcc4.7.3 and optimization flag set. Fix from 
issue #136 is in repo, but it is no closed

Original comment by masterpe...@gmail.com on 28 Nov 2013 at 5:47