Skip to content
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

Crash - Assertion failed at line 213 of src\core\kdtree.hpp: next != INVALID_NODE #7847

Closed
SamuXarick opened this issue Nov 29, 2019 · 7 comments · Fixed by #7849
Closed

Crash - Assertion failed at line 213 of src\core\kdtree.hpp: next != INVALID_NODE #7847

SamuXarick opened this issue Nov 29, 2019 · 7 comments · Fixed by #7849
Labels
bug

Comments

@SamuXarick
Copy link
Contributor

@SamuXarick SamuXarick commented Nov 29, 2019

Version of OpenTTD

1.10.0-beta1

Expected result

Actual result

Steps to reproduce

crash.zip

@LordAro LordAro changed the title kdtree crash report Crash - Assertion failed at line 213 of src\core\kdtree.hpp: next != INVALID_NODE Nov 29, 2019
@glx22

This comment has been minimized.

Copy link
Contributor

@glx22 glx22 commented Nov 29, 2019

 	[Code externe]	
 	openttd.exe!raise(int signum) Ligne 516	C++
 	openttd.exe!abort() Ligne 71	C++
>	openttd.exe!error(const char * s, ...) Ligne 129	C++
 	openttd.exe!Kdtree<ViewportSignKdtreeItem,int (__cdecl*)(ViewportSignKdtreeItem const &,int),int,int>::RemoveRecursive(const ViewportSignKdtreeItem & element, unsigned __int64 node_idx, int level) Ligne 213	C++
 	openttd.exe!Kdtree<ViewportSignKdtreeItem,int (__cdecl*)(ViewportSignKdtreeItem const &,int),int,int>::RemoveRecursive(const ViewportSignKdtreeItem & element, unsigned __int64 node_idx, int level) Ligne 216	C++
 	openttd.exe!Kdtree<ViewportSignKdtreeItem,int (__cdecl*)(ViewportSignKdtreeItem const &,int),int,int>::RemoveRecursive(const ViewportSignKdtreeItem & element, unsigned __int64 node_idx, int level) Ligne 216	C++
 	openttd.exe!Kdtree<ViewportSignKdtreeItem,int (__cdecl*)(ViewportSignKdtreeItem const &,int),int,int>::RemoveRecursive(const ViewportSignKdtreeItem & element, unsigned __int64 node_idx, int level) Ligne 216	C++
 	openttd.exe!Kdtree<ViewportSignKdtreeItem,int (__cdecl*)(ViewportSignKdtreeItem const &,int),int,int>::RemoveRecursive(const ViewportSignKdtreeItem & element, unsigned __int64 node_idx, int level) Ligne 216	C++
 	openttd.exe!Kdtree<ViewportSignKdtreeItem,int (__cdecl*)(ViewportSignKdtreeItem const &,int),int,int>::RemoveRecursive(const ViewportSignKdtreeItem & element, unsigned __int64 node_idx, int level) Ligne 216	C++
 	openttd.exe!Kdtree<ViewportSignKdtreeItem,int (__cdecl*)(ViewportSignKdtreeItem const &,int),int,int>::RemoveRecursive(const ViewportSignKdtreeItem & element, unsigned __int64 node_idx, int level) Ligne 216	C++
 	openttd.exe!Kdtree<ViewportSignKdtreeItem,int (__cdecl*)(ViewportSignKdtreeItem const &,int),int,int>::RemoveRecursive(const ViewportSignKdtreeItem & element, unsigned __int64 node_idx, int level) Ligne 216	C++
 	openttd.exe!Kdtree<ViewportSignKdtreeItem,int (__cdecl*)(ViewportSignKdtreeItem const &,int),int,int>::RemoveRecursive(const ViewportSignKdtreeItem & element, unsigned __int64 node_idx, int level) Ligne 216	C++
 	openttd.exe!Kdtree<ViewportSignKdtreeItem,int (__cdecl*)(ViewportSignKdtreeItem const &,int),int,int>::RemoveRecursive(const ViewportSignKdtreeItem & element, unsigned __int64 node_idx, int level) Ligne 216	C++
 	openttd.exe!Kdtree<ViewportSignKdtreeItem,int (__cdecl*)(ViewportSignKdtreeItem const &,int),int,int>::RemoveRecursive(const ViewportSignKdtreeItem & element, unsigned __int64 node_idx, int level) Ligne 216	C++
 	openttd.exe!Kdtree<ViewportSignKdtreeItem,int (__cdecl*)(ViewportSignKdtreeItem const &,int),int,int>::Remove(const ViewportSignKdtreeItem & element) Ligne 427	C++
 	openttd.exe!Station::~Station() Ligne 167	C++
 	[Code externe]	
 	[Cadre en ligne] openttd.exe!StationHandleBigTick(BaseStation *) Ligne 3419	C++
 	openttd.exe!OnTick_Station() Ligne 3842	C++
 	openttd.exe!CallLandscapeTick() Ligne 1397	C++
 	openttd.exe!StateGameLoop() Ligne 1390	C++
 	openttd.exe!GameLoop() Ligne 1478	C++
 	openttd.exe!VideoDriver_Win32::MainLoop() Ligne 1266	C++
 	openttd.exe!openttd_main(int argc, char * * argv) Ligne 862	C++
 	openttd.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Ligne 444	C++
 	[Code externe]	
@James103

This comment has been minimized.

Copy link
Contributor

@James103 James103 commented Nov 29, 2019

Sounds like a possible clone or resurgence of #7481 (related to signs).

@SamuXarick

This comment has been minimized.

Copy link
Contributor Author

@SamuXarick SamuXarick commented Nov 30, 2019

Station sign that is being removed
Unnamed, 1961-02-04

@SamuXarick

This comment has been minimized.

Copy link
Contributor Author

@SamuXarick SamuXarick commented Nov 30, 2019

autosave11.zip
Found a way to reproduce the crash in a timely manner.

1 - load the autosave
2 - scrollto 162326
3 - cheat to company 3
4 - demolish the dock and lower the 2 corners
5 - wait for the sign to disappear
... crash!

@nielsmh

This comment has been minimized.

Copy link
Contributor

@nielsmh nielsmh commented Nov 30, 2019

Confirm reproduction.

@nielsmh nielsmh added the bug label Nov 30, 2019
@nielsmh

This comment has been minimized.

Copy link
Contributor

@nielsmh nielsmh commented Nov 30, 2019

Lowering the land is not required for reproduction, it seems. The sign moves as soon as the station is demolished (station tiles removed), but the Kdtree position is not updated.

I think the best fix might be to modify Station::UpdateVirtCoord() so it compares the previous position stored in Station::sign to the new position, and update the tree if it doesn't match.

@nielsmh

This comment has been minimized.

Copy link
Contributor

@nielsmh nielsmh commented Nov 30, 2019

Another solution might be to change GetSlopePixelZ_Station() so it behaves the same as GetSlopePixelZ_Clear().

nielsmh added a commit to nielsmh/OpenTTD that referenced this issue Nov 30, 2019
…nates for stations

Keeping track of whether the ViewportSign data are valid for Kdtree usage allows moving more housekeeping to Station::UpdateVirtCoord and Waypoint::UpdateVirtCoord and helps simplify a lot of other code.
nielsmh added a commit to nielsmh/OpenTTD that referenced this issue Dec 1, 2019
…nates for stations

Keeping track of whether the ViewportSign data are valid for Kdtree usage allows moving more housekeeping to Station::UpdateVirtCoord and Waypoint::UpdateVirtCoord and helps simplify a lot of other code.
@nielsmh nielsmh closed this in #7849 Dec 1, 2019
nielsmh added a commit that referenced this issue Dec 1, 2019
…7849)

Ensure the same coordinates are used for station/town/player signs regardless of how the landscape changes below it after the coordinates were first determined.

By keeping track of whether each ViewportSign is valid for Kdtree use (and only ever registering the viewport sign when the object is valid) a lot of code can be simplified and become more robust at the same time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.