-
-
Notifications
You must be signed in to change notification settings - Fork 456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Linux]: Fix other crash in Garbage #1432
Conversation
src/xrGame/quadtree.h
Outdated
if (m_free == NULL) | ||
{ | ||
return NULL; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codestyle, plus it's better to leave VERIFY here, because it's not normal when m_free is null.
if (m_free == NULL) | |
{ | |
return NULL; | |
} | |
VERIFY(m_free); | |
if (!m_free) | |
return nullptr; | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partially fixed, but not fully because:
- We always use nullptr, NULL is not used (and is replaced to nullptr during code refactoring)
- We don't check for nullptr explicitly, where it's possible to not do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partially fixed, but not fully because:
1. We always use nullptr, NULL is not used (and is replaced to nullptr during code refactoring) 2. We don't check for nullptr explicitly, where it's possible to not do it.
Well there is need to check if we have nullptr, otherwise there is a crash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partially fixed, but not fully because:
1. We always use nullptr, NULL is not used (and is replaced to nullptr during code refactoring) 2. We don't check for nullptr explicitly, where it's possible to not do it.
Well there is need to check if we have nullptr, otherwise there is a crash.
I mean, we use if (!ptr)
of if (ptr)
checks rather than directly comparing to nullptr.
src/xrGame/quadtree_inline.h
Outdated
|
||
if (list_item == NULL) | ||
{ | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (list_item == NULL) | |
{ | |
return; | |
} | |
if (!list_item) | |
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
src/xrGame/quadtree_inline.h
Outdated
if (node == NULL) | ||
{ | ||
return NULL; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (node == NULL) | |
{ | |
return NULL; | |
} | |
VERIFY(node); | |
if (!node) | |
return nullptr; | |
src/xrGame/quadtree_inline.h
Outdated
@@ -102,6 +114,11 @@ IC void CSQuadTree::insert(_object_type* object) | |||
if (!*node) | |||
*node = m_nodes->get_object(); | |||
|
|||
if (node == NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node
gets dereferenced 3 lines above :D
Also, we are in the cycle here. I'm not sure at the moment if we should return or continue the cycle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now get_object() can return null, needs to check for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on code already there return is ok, continue causes crashes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now get_object() can return null, needs to check for it.
But here we check if node
is null, while get_object
assigns to *node
, not node
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now get_object() can return null, needs to check for it.
But here we check if
node
is null, whileget_object
assigns to*node
, notnode
🤔
Now get_object() can return null, needs to check for it.
But here we check if
node
is null, whileget_object
assigns to*node
, notnode
🤔
node is CQuadNode** node so *node is pointer I think? Otherwise it wouldn't compile.
6d41c16
to
49e4e0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the Files
tab of a pull request, you can just press Add suggestion to batch
and merge all my suggestions as one commit instead of porting them and recommiting manually.
So, I'm again here, with these suggestions. :)
We still need to leave those VERIFY in the code, because original devs assumed that it is not normal if m_free
is nullptr.
Since QuadTree is a generic container it's good to keep it robust with nullptr checks, but it's also good to keep these assertions (VERIFYs) for debugging purposes.
src/xrGame/quadtree_inline.h
Outdated
@@ -92,8 +92,16 @@ IC void CSQuadTree::insert(_object_type* object) | |||
if (depth == m_max_depth) | |||
{ | |||
CListItem* list_item = m_list_items->get_object(); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/xrGame/quadtree_inline.h
Outdated
list_item->m_object = object; | ||
list_item->m_next = (CListItem*)((void*)(*node)); | ||
|
||
if (!list_item->m_next ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!list_item->m_next ) | |
if (!list_item->m_next) |
For some reason game sometimes crashes while in Garbage.
Could you give me the save file with the crash? |
I started shooting at bandits and it crashed(it might take some time). |
Co-authored-by: Xottab_DUTY <Xottab-DUTY@users.noreply.github.com>
I hate that there are two commit then, I prefer fix commits manually. |
It's needed to be merged, without it I have rare but occurring crashes. |
@@ -102,6 +108,9 @@ IC void CSQuadTree::insert(_object_type* object) | |||
if (!*node) | |||
*node = m_nodes->get_object(); | |||
|
|||
if (!node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, back to the old discussion, we can't do *node
(dereference) two lines above if node
is nullptr
, so this if (!node)
check is actually late and we need to check for nullptr earlier.
For some reason game sometimes crashes while in Garbage.