• 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!

TFS 1.X+ [crash] Segmentation fault - Item::isRemoved

Sigoles

Discord: @sigoles
Joined
Nov 20, 2015
Messages
1,200
Solutions
2
Reaction score
149
I had this crash but I do not know how to reproduce, any idea guys?
tfs 1.2

Code:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff5323700 (LWP 2408)]
0x00000000004b353c in Item::isRemoved (this=<optimised out>) at /home/Otserver/src/item.h:1020
1020                return !parent || parent->isRemoved();

crash:
crash - Pastebin.com
 
i had that bug on 0.x, i don't remember what i did but it was between item.cpp and game.cpp i think. Can you post those files?
 
Last edited:
in item.h
C++:
bool isRemoved() const {
    return !parent || parent->isRemoved();
}

to
C++:
bool isRemoved() const {
    if (parent)
        return !parent || parent->isRemoved();
}
 
in item.h
C++:
bool isRemoved() const {
    return !parent || parent->isRemoved();
}

to
C++:
bool isRemoved() const {
    if (parent)
        return !parent || parent->isRemoved();
}

could u explain that change please? This is what i understood
if has parent (parent != null) then return true if not has parent (parent == null?) or parent isRemoved
 
If this piece is a fix for that crash, the correct would be:

C++:
bool isRemoved() const {
    return parent && parent->isRemoved();
}
 
This makes no sense, atleast I don't think.
You're right, it doesn't make any sense. Not only that, but it won't even compile.
If this piece is a fix for that crash, the correct would be:

C++:
bool isRemoved() const {
    return parent && parent->isRemoved();
}
This undoes the original purpose of the function. This will only return true if parent isn't null and parent is removed. The original function returns true if parent is null or if parent is removed.

@God Of Pain, the fact that the gdb logs show that the fault happens in Item::isRemoved() means that it's happening when dereferencing the parent pointer (parent->isRemoved()) and parent is pointing at invalid memory. My guess is that the parent is being deleted and not set null. It's going to be hard for anyone to help you without looking at your code, and any changes you've made prior to this fault happening.
 
You're right, it doesn't make any sense. Not only that, but it won't even compile.

This undoes the original purpose of the function. This will only return true if parent isn't null and parent is removed. The original function returns true if parent is null or if parent is removed.

@God Of Pain, the fact that the gdb logs show that the fault happens in Item::isRemoved() means that it's happening when dereferencing the parent pointer (parent->isRemoved()) and parent is pointing at invalid memory. My guess is that the parent is being deleted and not set null. It's going to be hard for anyone to help you without looking at your code, and any changes you've made prior to this fault happening.

You are right.
So the correct would be:

C++:
bool isRemoved() const {
    return !parent || parent->isRemoved();
}
 
Back
Top