Debugging

From ArcEmu-Wiki
Revision as of 08:44, 21 January 2011 by Marforius (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

So your arcemu crashed and you want some help (or want to post a crash report)? Very well - but due to how crash dump files work, you can only debug it on the machine it was compiled on with the same compiler it was compiled in. Which means you will have to do it.

Ico info.png WE CANNOT DEBUG REPACKS, report the bug to your REPACK's owner. We want nothing to do with it.


Warning: NEVER give your crash dump files to anyone else, they may contain personal information and will not be useful for actual debugging to anyone who does not have your compilation data.

Contents

Your report

Your report should contain at least the following info:

  • Revision you are using
  • If you are using a stable branch or trunk
  • World database and revision/version
  • Compiler used
  • Operating system and version
  • What external scripts you are using (if any)
  • Callstack, file/line at which it crashed and locals (see the next section)

In addition, if you're using an older revision, it's strongly recommended that you look in the SVN commits forum to see if the crash was already fixed.


Windows: Visual Studio

Requirements

  • The same compiler you originally compiled arcemu with (same version of Visual C++)
  • May not have recompiled arcemu using the same checkout; the file that crashed must be your current compile
  • May not have used "clean solution" since compiling
  • May not have moved the compilation directory


Opening your crash dump

When crashing, arcemu automatically makes a crash dump file located in the CrashDumps\ folder of your installation. If your arcemu is running on a different machine, you'll have to copy the crash dump over first. In Visual C++ go to File > Open > Project/Solution and open your crash dump file (or simply doubleclick the file in a file manager).

Once it opened the crash dump file you'll see it in the Solution Explorer on the left. Right click on it, go into the Debug submenu and click on "Step Into new instance".


Getting information

Visual C++ will automatically open the correct source file at the location of the crash. Select this line and write down the line number and filename. You can see the line number at the very bottom right of the window. You should also copy some of the code around your crash, put it in a [codebox] tag and mark the line at which it crashed with >>> signs. The crashing line is automatically highlighted in green in Visual C++.


File: field.h, line 36
 
	arcemu_INLINE uint16 GetUInt16() { return mValue ? static_cast<uint16>(atol(mValue)) : 0; }
>>>	arcemu_INLINE uint32 GetUInt32() { return mValue ? static_cast<uint32>(atol(mValue)) : 0; }
	arcemu_INLINE uint32 GetInt32() { return mValue ? static_cast<int32>(atol(mValue)) : 0; }
	uint64 GetUInt64() 
	{
		if(mValue)


Next, copy your call stack. The call stack tab is located in the bottom right. Select all of it and press copy. Place this in your forum post in another different [codebox] tag.


 	arcemu-world.exe!strtoxl(localeinfo_struct * plocinfo=0x006ddf70, const char * nptr=0x21852842
, const char * * endptr=0x00000000, int ibase=10, int flags=1)  Line 100 + 0x4 bytes	
 	arcemu-world.exe!strtoul(const char * nptr=0x21852842, char * * endptr=0x00000000, int ibase=10)  Line 262 + 0x7 bytes	
>	arcemu-world.exe!Field::GetUInt32()  Line 36 + 0x20 bytes	
 	arcemu-world.exe!ObjectMgr::LoadVendors()  Line 1044 + 0xb bytes	
 	arcemu-world.exe!CallbackP0<ObjectMgr>::operator()()  Line 51 + 0x1b bytes	
 	arcemu-world.exe!CallbackP0<CBattlegroundManager>::execute()  Line 52 + 0xf bytes	
 	arcemu-world.exe!Task::execute()  Line 4613	
 	arcemu-world.exe!TaskExecutor::run()  Line 4626	
 	arcemu-world.exe!thread_proc(void * param=0x01b2f638)  Line 262 + 0x11 bytes	
 	kernel32.dll!75e53833() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	
 	ntdll.dll!7758a9bd()


Finally, copy your locals. These are located in the bottom left. If you see a variable called "this", expand it; you shouldn't have to expand the rest most of the time. Select all and copy it into yet another [codebox] tag in your forum post.


-		this	0x07d6f228 {mValue=0x21852842 <Bad Ptr> }	Field * const
+		mValue	0x21852842 <Bad Ptr>	char *


That's it, you're done! Note that you should keep your crash dump files, you may be asked for more information later on if the developers think it would be helpful in figuring out how to fix it.


Linux: GDB

Linux users do not have to do anything but compile ArcEmu in "./configure prefix=/yourdir/ --enable-debug" mode to automatically submit crash reports (Make sure it is turned on inside of the configuration files and that you have not made any edits to the core. PLEASE if you are making edits to the core for a repack or personal server TURN CRASHREPORTING OFF, it will only add to the unhelpful amount of crashes already on the Trac. If you are developing a server you are responsible for your own code; not us. For those that wish to do this manually, or are developing a server on Linux - here is the guide.

Ico info.png

If you have found a bug that you believe is in our code, report it on our trac or forums - but please do verify that the bug is our(s). It would be reccomended to include PDB files for us to use (These should be created at compile-time in debug mode.).



To view a basic backtrace using GDB, locate your core.#### (Replace #### with your crash number) dump and type:


gdb arcemu-world core.####


This will bring up a backtrace menu. If you open a crash dump from the "arcemu-logonserver" you will get an error like:


gdb arcemu-world core.####
 
warning: core file may not match specified executable file.
Core was generated by `/opt/abadon/bin/arcemu-logonserver'.
Program terminated with signal 6, Aborted.
#0  0x00ca6402 in __kernel_vsyscall ()
(gdb)


This means that the crash dump came from the logonserver, and you would then need to type:


gdb arcemu-logonserver core.####


Here is an example of what you will get when you run gdb on a crashdump:


....
Loaded symbols for ../lib/libQuestScripts.so
Reading symbols from /opt/abadon/lib/libServerStatusPlugin.so...done.
Loaded symbols for ../lib/libServerStatusPlugin.so
Reading symbols from /opt/abadon/lib/libSpellHandlers.so...done.
Loaded symbols for ../lib/libSpellHandlers.so
Reading symbols from /opt/abadon/lib/libLUAScripting.so...done.
Loaded symbols for ../lib/libLUAScripting.so
Reading symbols from /opt/abadon/lib/libMoonGossipScripts.so...done.
Loaded symbols for ../lib/libMoonGossipScripts.so
Core was generated by `/opt/abadon/bin/arcemu-world'.
Program terminated with signal 6, Aborted.
#0  0x00ca6402 in __kernel_vsyscall ()
(gdb)


This means GDB has loaded debug information for the arcemu-world bin file, what you want to look for is the #0, this is where the crash began, to view a full list of them in short mode you can type:


(gdb) bt
 
#0  0x00ca6402 in __kernel_vsyscall ()
#1  0x007c9ba0 in raise () from /lib/libc.so.6
#2  0x007cb5fe in abort () from /lib/libc.so.6
#3  0x007ffdfb in __libc_message () from /lib/libc.so.6
#4  0x00807aa6 in _int_free () from /lib/libc.so.6
#5  0x0080afc0 in free () from /lib/libc.so.6
#6  0x03e01671 in operator delete () from /usr/lib/libstdc++.so.6
#7  0x0818f79f in ChatHandler::HandleGODelete (this=0xaa1e048, args=0x9f68e50e "", m_session=0xa1eb6dd0) at Level2.cpp:644
#8  0x0813cedd in ChatHandler::ExecuteCommandInTable (this=0xaa1e048, table=0xaa1fa6c, text=0x9f68e50e "", m_session=0xa461ca10) at Chat.cpp:683
#9  0x0813ce6d in ChatHandler::ExecuteCommandInTable (this=0xaa1e048, table=0xaa23698, text=0x9f68e508 "delete", m_session=0xa461ca10) at Chat.cpp:648
#10 0x0813d1c4 in ChatHandler::ParseCommands (this=0xaa1e048, text=0x9f68e504 ".go delete", session=0xa461ca10) at Chat.cpp:719
#11 0x0813eb34 in WorldSession::HandleMessagechatOpcode (this=0xa461ca10, recv_data=@0xa1e62850) at ChatHandler.cpp:152
#12 0x083299b9 in WorldSession::Update (this=0xa461ca10, InstanceID=<value optimized out>) at WorldSession.cpp:173
#13 0x081d2633 in MapMgr::_PerformObjectDuties (this=0xa9decf40) at MapMgr.cpp:1615
#14 0x081d2bb9 in MapMgr::Do (this=0xa9decf40) at MapMgr.cpp:1379
#15 0x081d2e01 in MapMgr::run (this=0xa9decf40) at MapMgr.cpp:1316
#16 0x0833ba04 in thread_proc (param=0xa9dfffb0) at Threading/ThreadPool.cpp:319
#17 0x0091745b in start_thread () from /lib/libpthread.so.0
#18 0x0086f24e in clone () from /lib/libc.so.6
(gdb)


We can now see that the crash began on #7 with the ChatHandler function in Level2.cpp line 644. Also note that even if you have not used "--enable-debug" option when running configure you can still find some helpful problems for the arcemu Devs, or for your own use. Now, to pull up a full backtrace type the following:


(gdb) bt full
#0  0x00ca6402 in __kernel_vsyscall ()
No symbol table info available.
#1  0x007c9ba0 in raise () from /lib/libc.so.6
No symbol table info available.
#2  0x007cb5fe in abort () from /lib/libc.so.6
No symbol table info available.
#3  0x007ffdfb in __libc_message () from /lib/libc.so.6
No symbol table info available.
#4  0x00807aa6 in _int_free () from /lib/libc.so.6
No symbol table info available.
#5  0x0080afc0 in free () from /lib/libc.so.6
No symbol table info available.
#6  0x03e01671 in operator delete () from /usr/lib/libstdc++.so.6
No symbol table info available.
#7  0x0818f79f in ChatHandler::HandleGODelete (this=0xaa1e048, args=0x9f68e50e "", m_session=0xa1eb6dd0) at Level2.cpp:644
        cellx = 293
        celly = 278
        GObj = (class GameObject *) 0xa5a00010
#8  0x0813cedd in ChatHandler::ExecuteCommandInTable (this=0xaa1e048, table=0xaa1fa6c, text=0x9f68e50e "", m_session=0xa461ca10) at Chat.cpp:683
        cmd = {static npos = 4294967295, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
    _M_p = 0x9edf063c "delete"}}
#9  0x0813ce6d in ChatHandler::ExecuteCommandInTable (this=0xaa1e048, table=0xaa23698, text=0x9f68e508 "delete", m_session=0xa461ca10) at Chat.cpp:648
        cmd = {static npos = 4294967295, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x9f68b434 "go"}}
#10
...

This can at times output a load of information, write down only the first few #'s starting with the crash, you do not need every single #', as the crash will cause normal functions and calls to fail, even if they work perfectly, it all depends on where the crash begins. Make sure to compile in with "--enable-debug" so that you can report more useful data to arcemu.

Not all crashes are caused by arcemu, many come from faulty scripts or invalid database data. They can come from low memory on your system or CPU limitations. Before you report these to arcemu take a look at them and check where they crash, of they seem to crash in a core related file (Such as Chat.cpp) and you have made no modifications to the file, then report them to arcemu.

To quit GDB's menu, type:

(gdb) quit

Mac OSX: XCode

(instructions needed)

Personal tools