Skip to content
This repository has been archived by the owner on Sep 16, 2018. It is now read-only.

Game server crash #65

Open
JuneStepp opened this issue Jun 29, 2018 · 5 comments
Open

Game server crash #65

JuneStepp opened this issue Jun 29, 2018 · 5 comments

Comments

@JuneStepp
Copy link
Contributor

JuneStepp commented Jun 29, 2018

The game server crashes with:

manaserv-game: sourceoftales/manaserv/src/game-server/entity.h:140: T* Entity::getComponent() const [with T = ActorComponent]: Assertion `component' failed.

To reproduce:

  1. Start a conversation with an npc.
  2. While in the conversation walk away from the npc. You can tell you are far enough away if the miniature icon of the npc disappears from your dialogue box. You do not have to be that faraway though.
  3. Click the button to progress the dialogue.

After that you should see a loading symbol until the game servers eventually crash.

What I am about to say doesn't belong in a bug report but it seems like dialogues should automatically close if a player gets too faraway from an npc.

I have done some more investigation and I have found out that most of the time the crash is triggered by pressing the button to progress dialogue again after step 3 in what I said earlier after moving close to the npc again.

@bjorn
Copy link
Member

bjorn commented Jun 29, 2018

Would be useful to see the full backtrace instead of just the line of the assertion, which may give us an idea of where the entity pointer came from and why it may not have an actor component. Do you know how to use gdb to get it?

@JuneStepp
Copy link
Contributor Author

No I don't know how to get that output but I have output from "dbg".

@bjorn
Copy link
Member

bjorn commented Jun 29, 2018

In short it works like this:

  • Launch the server in the debugger using gdb manaserv-game and then type run to start it.
  • Once you got it to crash, type bt or bt full to get a backtrace, or a full backtrace that has the values of local variables included.

@JuneStepp
Copy link
Contributor Author

JuneStepp commented Jun 29, 2018

This is what it gave me:

> #0  0x00007ffff6574428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
        resultvar = 0
        pid = 25649
        selftid = 25649
#1  0x00007ffff657602a in __GI_abort () at abort.c:89
        save_stage = 2
        act = {__sigaction_handler = {sa_handler = 0x4, sa_sigaction = 0x4}, sa_mask = {__val = {18374966855136706815, 0, 
              140737488343360, 47244640390, 140737354096640, 6182465, 140, 6182496, 0, 0, 140737326626108, 140737327723088, 
              140737327736736, 0, 140737327723088, 6182465}}, sa_flags = -134258688, sa_restorer = 0x5e5641}
        sigs = {__val = {32, 0 <repeats 15 times>}}
#2  0x00007ffff656cbd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x5e5641 "component", 
    file=file@entry=0x5e55f0 "/home/jeremy/Desktop/Dev_Stuff/Source_of_Tales/manaserv/src/game-server/entity.h", 
    line=line@entry=140, 
    function=function@entry=0x5e5660 <ActorComponent* Entity::getComponent<ActorComponent>() const::__PRETTY_FUNCTION__> "T* Entity::getComponent() const [with T = ActorComponent]") at assert.c:92
        str = 0xd74420 "x;\220\366\377\177"
        total = 4096
#3  0x00007ffff656cc82 in __GI___assert_fail (assertion=0x5e5641 "component", 
    file=0x5e55f0 "/home/jeremy/Desktop/Dev_Stuff/Source_of_Tales/manaserv/src/game-server/entity.h", line=140, 
    function=0x5e5660 <ActorComponent* Entity::getComponent<ActorComponent>() const::__PRETTY_FUNCTION__> "T* Entity::getComponent() const [with T = ActorComponent]") at assert.c:101
No locals.
#4  0x000000000053b9b5 in ActorComponent* Entity::getComponent<ActorComponent>() const ()
No symbol table info available.
#5  0x000000000057bad4 in findActorNear(Entity*, int) ()
No symbol table info available.
#6  0x000000000057cb10 in GameHandler::handleNpc(GameClient&, MessageIn&) ()
No symbol table info available.
#7  0x000000000057be8a in GameHandler::processMessage(NetComputer*, MessageIn&) ()
No symbol table info available.
#8  0x000000000052a872 in ConnectionHandler::process(unsigned int) ()
No symbol table info available.
#9  0x000000000053371d in main ()
No symbol table info available.

@bjorn
Copy link
Member

bjorn commented Jun 29, 2018

Hmm, unfortunately your version of manaserv-game was compiled without debug information, otherwise the backtrace would have included file name and line number information.

findActorNear calls getComponent on two lines, so now we're not sure on which line it referenced an entity that did not have an ActorComponent. But it seems like the client sent the server a valid entity ID of an entity that did not have this component. Of course that should not be able to crash the server, so it should use findComponent instead of getComponent on the entity found by the ID provided by the client.

But apart from avoiding the crash there is probably something else that should be fixed here, since the client is not expected to send NPC messages with an invalid NPC ID.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants