The International Simutrans Forum

Simutrans Extended => Simutrans-Extended development => Simutrans-Extended bug reports => Topic started by: Ranran(retired) on May 25, 2021, 04:28:33 AM

Title: [Crash] Game crash due to camera rotation
Post by: Ranran(retired) on May 25, 2021, 04:28:33 AM
The game always crashes when I rotate the camera a few times.
Can be reproduced with demo save.
(https://i.imgur.com/tZnlVt3.png)


This cannot be reproduced with at least the May 2 version (# 7289be5)
Title: Re: [Crash] Game crash due to camera rotation
Post by: Ranran(retired) on May 27, 2021, 11:29:55 PM
This turned out to crash in the same part as the crash bug I reported here (https://forum.simutrans.com/index.php/topic,20878.msg195597.html#msg195597). It's due to coomit d61a1a9bda0261a36d261c65090b4d6466427506.

A crash may occur even if you do not rotate the camera, but you can reproduce it 100% (in demo.sve) by rotating the camera.
Title: Re: [Crash] Game crash due to camera rotation
Post by: PJMack on May 28, 2021, 10:50:44 PM
I had forgotten to test whether my pull request works with "camera" rotation, for that I apologize. 

I am currently still trying to sort out what exactly the issue is, as the debugging information shows the system in in invalid state which is physically impossible to get into.  Furthermore, whenever a breakpoint is added to the karte_t::rotate90 function, the crash is unlikely to occur!  Valgrind also appears to reduce the likelihood of failure, however for the few failures I did capture, Valgrind showed no relevant issues.  This leads me to believe that some sort of race condition is occurring.  Defining NO_PRIVATE_CAR_DESTINATION_LINKING (weg.cc line 1975) appears to mitigate the problem, however I currently do not know whether it actually prevents the race condition, or just significantly decreases the likelihood of it.  I did make sure that the mutex protections were in all the same places as previously. 
Title: Re: [Crash] Game crash due to camera rotation
Post by: prissi on May 29, 2021, 01:21:03 PM
Since experimental uses threading for route finding: Are all routefinding threads terminated before rotation?
Title: Re: [Crash] Game crash due to camera rotation
Post by: PJMack on May 29, 2021, 04:43:02 PM
As far as I can tell, the threads are terminated, but there is nothing to prevent them from starting again before the rotation in finished.  The same is true for the weg_t destructor function.

Edit:
Nevermind, I found it in the sync-step function.
Title: Re: [Crash] Game crash due to camera rotation
Post by: PJMack on May 30, 2021, 07:12:20 PM
I found the issue, and the crash is cause by my code.  I had made an assumption that roads do not move in relation to one another.  It appears that private car routing never handled map rotation properly, it is just that my code caused a crash rather than cars getting lost.  I am trying to fix it now.  Again, I apologize for this.
Title: Re: [Crash] Game crash due to camera rotation
Post by: PJMack on May 30, 2021, 09:08:03 PM
I have submitted a pull request making the compression/linking tolerant of map rotation.  As it was before I came along, map rotation causes cars to become lost, hence the term "tolerant" despite preventing the crash from that particular issue entirely. 

For as to why the breakpoints prevented the issue, I am still not sure.  Is it possible that the breakpoints cause the map rotation to occurred between the find_route cycles (?!)... 

As neither network games, private car routing, nor regions (https://forum.simutrans.com/index.php/topic,20773.0.html (https://forum.simutrans.com/index.php/topic,20773.0.html)) fully supported map rotation (as of me joining), has it become a depreciated?
Title: Re: [Crash] Game crash due to camera rotation
Post by: prissi on May 31, 2021, 01:31:03 AM
The networkgames could support map rotation. However, it would rotate the map for all players at the same time. Hence it was disabled. One could think enabling map rotation when only one client is connected ...

The private car routing and regions are quite new.
Title: Re: [Crash] Game crash due to camera rotation
Post by: Mariculous on May 31, 2021, 10:43:23 AM
Quote from: prissi on May 31, 2021, 01:31:03 AMOne could think enabling map rotation when only one client is connected ...
Please don't!
Playing on a rotated map can be quite confusing, and not being able to rotate it back unless there's only one player connected seems quite annoying to me.
So please don't enable the feature this way.