The International Simutrans Forum

 

Author Topic: Fix for data race in plans_finish_rd  (Read 564 times)

0 Members and 1 Guest are viewing this topic.

Offline ceeac

  • Devotee
  • *
  • Posts: 269
Fix for data race in plans_finish_rd
« on: April 30, 2020, 05:48:51 PM »
The read access to min_height and max_height at the beginning of karte_t::plans_finish_rd needs to be synchronized since another thread might be writing to any of these two variables.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4899
  • Languages: EN, DE, AT
Re: Fix for data race in plans_finish_rd
« Reply #1 on: May 01, 2020, 07:21:53 AM »
Imho no mutex is needed. It would be sufficient to initialize those values with -128 and +127. The writing to min//max_height is already protected by some mutex.

Offline ceeac

  • Devotee
  • *
  • Posts: 269
Re: Fix for data race in plans_finish_rd
« Reply #2 on: May 01, 2020, 08:38:44 AM »
Yes, that would work too. :)

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4899
  • Languages: EN, DE, AT
Re: Fix for data race in plans_finish_rd
« Reply #3 on: May 02, 2020, 09:43:26 AM »
implemented in r9060