Re: CVS GTK version dies on startup? :(


Subject: Re: CVS GTK version dies on startup? :(
From: Dom Lachowicz (dominicl@seas.upenn.edu)
Date: Wed Oct 31 2001 - 11:38:44 CST


Quoting Tomas Frydrych <tomas@frydrych.uklinux.net>:

> This is exactly the same problem that we were having couple of
> days ago. I spent good five hours tracing this then, and it was
> caused by creating a temporary copy of the menu string vector on
> the stack resulting in stack overflow (the reason why the id did not
> match getMenuId was that the cretion of the temporary copy on the
> stack overwriten part of the heap in use). We really need to find out
> why the debug build is running out of stack space and fix that, this
> not going to go away even if it works with the current configuration,
> it merely means that the heap is used differently, but it is going to
> come back to haunt us.

Answer: stop making temporary copies on the stack. Seriously - assume we have
a function that looks like this:

MyClass & myFunc();

Do *not* do this:

// create copy of a reference
MyClass c = myFunc ();

Instead, do this:

// just a reference
MyClass &c = myFunc ();

Passing around pointers when we don't need to sucks - we have to then do
checks for null and such problems. Motto: references are usually your friends.

Dom



This archive was generated by hypermail 2b25 : Wed Oct 31 2001 - 11:38:53 CST