The International Simutrans Forum

 

Author Topic: Small patches resulting from valgrind  (Read 1858 times)

0 Members and 1 Guest are viewing this topic.

Offline neroden

  • Devotees (Inactive)
  • *
  • Posts: 831
  • Nathanael Nerode
Small patches resulting from valgrind
« on: July 02, 2013, 07:51:44 PM »
I've been running valgrind on experimental to attempt to track down some memory corruption errors.  I've been patching everything I find.  A few of the patches should be applied to standard as well.  This will contain them.  First one is a tiny patch to simmain.


Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4898
  • Languages: EN, DE, AT
Re: Small patches resulting from valgrind
« Reply #1 on: July 02, 2013, 07:58:08 PM »
I have never got a valgrind warning at this point. How did you trigger it?

Offline neroden

  • Devotees (Inactive)
  • *
  • Posts: 831
  • Nathanael Nerode
Re: Small patches resulting from valgrind
« Reply #2 on: July 03, 2013, 10:19:14 PM »
By turning on optimization flags, I think. 

This is a real bug.  The problem is that ev is an uninitialized variable under certain circumstances, namely when the modal dialogue disappears really really fast and you never make it into either of the main loops up above.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 5695
  • Languages: EN, NO
Re: Small patches resulting from valgrind
« Reply #3 on: July 04, 2013, 04:35:43 AM »
Is there any way for a modal dialog to immediately disappear without inputs other than quit returning true from the start? If not, it might be better to just wrap the entire contents of the function in an if checking quit(). Reading input just to initialize a variable doesn't feel right.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4898
  • Languages: EN, DE, AT
Re: Small patches resulting from valgrind
« Reply #4 on: July 04, 2013, 06:20:40 AM »
Imho we should just initialize all member variables of event_t in its constructors.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10819
  • Languages: De,EN,JP
Re: Small patches resulting from valgrind
« Reply #5 on: July 04, 2013, 09:33:49 PM »
This sound also like the best solution for me.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4898
  • Languages: EN, DE, AT
Re: Small patches resulting from valgrind
« Reply #6 on: October 25, 2013, 05:42:36 PM »
in r6852