The International Simutrans Forum

 

Author Topic: [Crash] Game crash due to camera rotation  (Read 457 times)

0 Members and 1 Guest are viewing this topic.

Offline Ranran

  • Devotee
  • *
  • Posts: 1511
  • Languages: ja
[Crash] Game crash due to camera rotation
« 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.



This cannot be reproduced with at least the May 2 version (# 7289be5)
« Last Edit: May 27, 2021, 11:20:03 PM by Ranran »

Offline Ranran

  • Devotee
  • *
  • Posts: 1511
  • Languages: ja
Re: [Crash] Game crash due to camera rotation
« Reply #1 on: May 27, 2021, 11:29:55 PM »
This turned out to crash in the same part as the crash bug I reported here. 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.
« Last Edit: May 28, 2021, 12:02:07 AM by Ranran »

Offline PJMack

  • *
  • Posts: 28
Re: [Crash] Game crash due to camera rotation
« Reply #2 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. 

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10642
  • Languages: De,EN,JP
Re: [Crash] Game crash due to camera rotation
« Reply #3 on: May 29, 2021, 01:21:03 PM »
Since experimental uses threading for route finding: Are all routefinding threads terminated before rotation?

Offline PJMack

  • *
  • Posts: 28
Re: [Crash] Game crash due to camera rotation
« Reply #4 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.
« Last Edit: May 30, 2021, 07:02:15 PM by PJMack »

Offline PJMack

  • *
  • Posts: 28
Re: [Crash] Game crash due to camera rotation
« Reply #5 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.

Offline PJMack

  • *
  • Posts: 28
Re: [Crash] Game crash due to camera rotation
« Reply #6 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) fully supported map rotation (as of me joining), has it become a depreciated?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10642
  • Languages: De,EN,JP
Re: [Crash] Game crash due to camera rotation
« Reply #7 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.

Offline Freahk

  • Devotee
  • *
  • Posts: 1504
  • Languages: DE, EN
Re: [Crash] Game crash due to camera rotation
« Reply #8 on: May 31, 2021, 10:43:23 AM »
One 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.