The International Simutrans Forum

 

Author Topic: [Fix] Crashes when desynchronising from a server in some cases  (Read 1573 times)

0 Members and 1 Guest are viewing this topic.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
[Fix] Crashes when desynchronising from a server in some cases
« on: September 30, 2017, 10:20:53 AM »
I have recently found and fixed on Extended recently a crash bug that occurs in identical code to Standard: see here for the Github commit. The solution is quite straightforward, as will be apparent from the commit.

The bug involves a double free of the "nwc" object when a connecting client disconnects from a server. The fix checks whether the first delete operation has occurred and makes the second delete operation conditional on that check.

I vaguely remember this being reported as having been an intermittent problem for some time. It only affects clients, not servers.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4594
  • Languages: EN, DE, AT
Re: [Fix] Crashes when desynchronising from a server in some cases
« Reply #1 on: October 01, 2017, 09:19:51 AM »
thanks for the post! This could have been fixed also by removing the 'delete nwc' in do_network_world_command?

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Fix] Crashes when desynchronising from a server in some cases
« Reply #2 on: October 01, 2017, 09:29:42 AM »
I am not sure - might this not have lead to a memory leak if necessary was not deleted elsewhere? I am not sure what the purpose of this was.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4594
  • Languages: EN, DE, AT
Re: [Fix] Crashes when desynchronising from a server in some cases
« Reply #3 on: October 01, 2017, 09:38:13 AM »
To me it looks like a double-delete. Will check later.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Fix] Crashes when desynchronising from a server in some cases
« Reply #4 on: October 01, 2017, 10:47:22 AM »
Yes, the crash was of a double free type.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4594
  • Languages: EN, DE, AT
Re: [Fix] Crashes when desynchronising from a server in some cases
« Reply #5 on: October 01, 2017, 04:13:42 PM »
Removed the double delete command, see r8299.