-
Notifications
You must be signed in to change notification settings - Fork 154
Debugging Segment Faults (crash dump)
- Your PvPGN must be compiled in
Debug
mode.
a) The mode can be switched from Release
to Debug
in Magic Builder (pvpgn_build.bat
line 323).
Change ... /p:Configuration=Release ...
→ ... /p:Configuration=Debug ...
on that line. After build save a file build\src\bnetd\Debug\bnetd.pdb
b) Use Magic Builder script build_pvpgn_dev.bat to create Visual Studio solution. Open pvpgn.sln
, select bnetd and switch project mode to Debug and build the project. After a compilation copy a file bnetd.pdb
.
- Run
PvPGN.exe
and reproduce a server crash. A dump file should be appear in the directory with a name likePvPGN_20141025_191719.dmp
:
- Create a new issue with a bug report (including reproduction steps).
a) Attach *.dmp
(crash dump), *.pdb
(symbols) and pvpgn.exe
to an issue, so developers can explore it.
b) Explore a dump file yourself using Visual Studio. For this open a dump file, set path to symbols file and start debugging. The IDE should break on the line in code where the program was crashed.
- First you have to compile
bnetd
with additional symbolic debugging information. It can be done by passing-g
command line parameter to gcc compiler. Otherwise,gdb
will not show the line from the source code where the server process terminated.
You can do this by adding a new flag when generatIng files with cmake: -D CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -g"
.
For example:
cmake -D CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -g" -D WITH_MYSQL=true -D WITH_LUA=true ../
2. Run make && make install
as usual to build and install PvPGN files.
-
Run command
ulimit -c
. If output is0
then set it to unlimit by runningulimit -c unlimited
. Otherwise, a crash dump will not be written to a file. -
Run PvPGN from
/usr/local/sbin/bnetd
and reproduce a server crash. Crash dumps should be written into a file namedcore
. On my system it appears in the root directory/
, so full path to the file is/core
. On your system, it can be located near the programbnetd
and with other file name likecore.12345
where 12345 is thebnetd
process id. -
Install gdb with
apt-get install gdb
. Open a crash dump file using syntaxgdb PATH_TO_BNETD PATH_TO_CRASH_DUMP
. For example:gdb /usr/local/sbin/bnetd /core
# gdb bnetd /core
GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/local/sbin/bnetd...done.
[New LWP 5364]
warning: Can't read pathname for load map: Input/output error.
Core was generated by `bnetd'.
Program terminated with signal 11, Segmentation fault.
#0 0x00000000005191e2 in eventlog_startup () at /home/pvpgn/src/bnetd/main.cpp:179
warning: Source file is more recent than executable.
179 return *(int*)0;
(gdb)
Here you can see that the segfault is on line 179 return *(int*)0;
(I added this test code specifically to make this crash).
Write bt full
— this will show a full stack trace:
(gdb) bt full
#0 0x00000000005191e2 in eventlog_startup () at /home/pvpgn/src/bnetd/main.cpp:179
__FUNCTION__ = "eventlog_startup"
#1 0x0000000000519bfc in main (argc=1, argv=0x7fff6a01cd28) at /home/pvpgn/src/bnetd/main.cpp:516
a = 0
pidfile = 0x0
__FUNCTION__ = "main"
(gdb) q
#
To exit from gdb send q
.
Well, now copy all the output text from gdb
utility, upload to http://pastebin.com and create a new issue with a bug report (including reproduction steps).