• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Linux Segmentation fault ?

Yaze

Well-Known Member
Joined
Sep 15, 2014
Messages
382
Reaction score
61
Hello everyone,

i need help here, today i've started my ots and about 5times it did crash, and always in server log was

"segmentation fault" ?

How can i see why it crashes and how to fix it, would be kind to get fast answers..
edit:

im using 0.3.6, 8.6 client

thanks, kind regards,

Yaze
 
You could install the GNU Debugger(GDB) and debug the application. It would be best if you compiled your server with debugging symbols to make the most of the debugger. Also you will probably need a programmer to fix the problem for you.
 
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff465c700 (LWP 10798)]
0x00000000005836f8 in Tile::__getThing (this=0x6b1bb2e0, index=<optimized out>)
at tile.cpp:1486
1486 if(item && !item->isRemoved())



thats the error i get ..
@dominique120
this problem comes from my sources , btw my tfs or from ots?
 
You'll need to recompile the server with debugging symbols (IIRC you need to set the proper flag in ./configure), then run it in GDB and use the bt command to give us a call stack.
 
Could you give me a turtorial for this please? @Damc

bump :/

My ots is keep crashing even with my sources i use in OTHER ots where it dont crash-.- ..
 
Last edited by a moderator:
This:
Code:
./configure --help
should print all available compile-time flags for the server. Look for something called -D_DEBUG and then use the configure script again with that flag (and the MySQL db one). Once the sources are configured, just use these commands:
Code:
make clean && make -j number_of_hardware_threads_of_execution
Don't forget to change number_of_hardware_threads_of_execution to match your CPU core number. Once the server compiles, run gdb and then use the following commands:
Code:
file ots_binary_name
run
When the server crashes run:
Code:
info locals
info args
bt
 
root@ns3280051:/home/ots/trunk.r3884# ./configure --help | grep 'mysql\|debug'
--enable-debug enable debuging
--enable-mysql enable MySQL support
 
Execute this:
Code:
./configure --enable-mysql --enable-debug
Code:
make clean
Code:
make -j `nproc`
Remove the -j `nproc` if you get odd errors(they are caused by being out of memory.)

Once you have compiled do what DamC said, specifically the last two code boxes.
 
i did use the GBD and this is after the crash.


Code:
root@ns3280051:/home/otsmanager/forgottenserver# gdb tfs core.pid
GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7
Copyright (C) 2014 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".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from tfs...done.
[New LWP 4580]
[New LWP 4579]
[New LWP 4688]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./tfs --log-file output.txt error.txt'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000702ec06aa in ?? ()
(gdb) bt
#0  0x0000000702ec06aa in ?? ()
#1  0x000000000057af59 in Tile::__queryDestination (this=<optimised out>,
    index=<optimised out>, thing=<optimised out>, destItem=0x7fded5b8d9a8,
    flags=@0x7fded5b8d998: 1) at tile.cpp:874
#2  0x000000000046a237 in Game::internalAddItem (
    this=this@entry=0x82f260 <g_game>, actor=actor@entry=0x0,
    toCylinder=<optimised out>, item=item@entry=0x7fde6df0dc50,
    index=index@entry=-1, flags=flags@entry=1, test=test@entry=false)
    at game.cpp:1564
#3  0x000000000046ce06 in Game::combatChangeHealth (this=0x82f260 <g_game>,
    combatType=COMBAT_PHYSICALDAMAGE, attacker=attacker@entry=0x7fdeb49660f0,
    target=target@entry=0x7fdebebfb510, healthChange=<optimised out>,
    hitEffect=MAGIC_EFFECT_UNKNOWN, hitColor=TEXTCOLOR_UNKNOWN,
    force=force@entry=false) at game.cpp:4316
#4  0x0000000000427e21 in Combat::CombatHealthFunc (
    caster=caster@entry=0x7fdeb49660f0, target=target@entry=0x7fdebebfb510,
    params=..., data=data@entry=0x7fded5b8db30) at combat.cpp:553
#5  0x000000000042a840 in Combat::doCombatHealth (
    caster=caster@entry=0x7fdeb49660f0, target=target@entry=0x7fdebebfb510,
    minChange=-82631, maxChange=-82631, params=...) at combat.cpp:839
#6  0x00000000005854b9 in Weapon::internalUseWeapon (
    this=this@entry=0x7fdec27ca300, player=player@entry=0x7fdeb49660f0,
    item=item@entry=0x7fde77aae1b0, target=target@entry=0x7fdebebfb510,
 
First of all I don't really use Linux, but I said I'd try to help so I will.

So when you START your server it crashes? How fast does it crash?
Do you know where exactly it crashes in the console?
 
No it takes like 20-40 minutes, then it crashs.
No i dont know where , it just goes offline and in server log is like only "Segmentation Fault"
 
No it takes like 20-40 minutes, then it crashs.
No i dont know where , it just goes offline and in server log is like only "Segmentation Fault"

Ok good, then some function is crashing the server.

Above you suggest it is inside tile.cpp but of course I couldn't be sure.

You will need to do your own testing, or compare your tile.cpp to other sources. But if your server is online for 20-40 minutes and gives you the same error each time it crashes, then you know exactly what is wrong, and should just compare it to other sources.
 
i did but i couldnt compile tfs after i did change the tile.cpp game.cpp combat.cpp weapons.cpp, gave me some error after i did "make"
 
Last edited:
Post the function that runs row 874 in tile.cpp and function that runs row 839 in combat.cpp

What kind of tiles/movement functions do you use to damage players? Did you modify the source anything? What did you add if you did?
 
line 874 - tile.cpp
if(destThing && !destThing->isRemoved())
line 839 - combat.cpp
CombatHealthFunc(caster, target, params, (void*)&var);

No ididnt modify the source.
Even with clean sources downloaded from otland it crashs.
I had a movement that if u walk on blood splash, it crated blood on 3-4 more tiles when u walk over it, but i deleted that movement and it still crashs..
 
Code:
(gdb) bt
#0  0x00007f7c00000001 in ?? ()
#1  0x000000000057b9c6 in Tile::updateTileFlags (
    this=this@entry=0x7f7c1eb78840, item=item@entry=0x7f7c7a493540,
    removed=removed@entry=true) at tile.cpp:1794
#2  0x000000000057bf1e in Tile::__replaceThing (this=0x7f7c1eb78840,
    index=<optimised out>, thing=<optimised out>) at tile.cpp:1148
#3  0x000000000046bb78 in Game::transformItem (
    this=this@entry=0x82f260 <g_game>, item=item@entry=0x7f7c524c7130,
    newId=3107, newCount=newCount@entry=-1) at game.cpp:2054
#4  0x000000000046c2f1 in Game::internalDecayItem (
    this=this@entry=0x82f260 <g_game>, item=item@entry=0x7f7c524c7130)
    at game.cpp:4565
#5  0x0000000000471416 in Game::checkDecay (this=0x82f260 <g_game>)
    at game.cpp:4602
#6  0x0000000000479876 in operator() (p=<optimised out>, this=<optimised out>)
    at /usr/include/boost/bind/mem_fn_template.hpp:49
#7  operator()<boost::_mfi::mf0<void, Game>, boost::_bi::list0> (
    a=<synthetic pointer>, f=..., this=<optimised out>)
    at /usr/include/boost/bind/bind.hpp:253
#8  operator() (this=<optimised out>)
    at /usr/include/boost/bind/bind_template.hpp:20
#9  boost::detail::function::void_function_obj_invoker0<boost::_bi::bind_t<void, boost::_mfi::mf0<void, Game>, boost::_bi::list1<boost::_bi::value<Game*> > >, v---Type <return> to continue, or q <return> to quit---

this is the error..
 
Back
Top