Re: [gtk-list] Re: Gtk--: Tracking down clobbered pointers and mysterious crashes



robert_gasch@peoplesoft.com writes:
> I forgot to mention: the reason I suspected object creation on
> the stack to be a potential problem is that a while ago I experienced
> some rather hard to debug crashes where the stack was clobbered
> into oblivion. The cause of these turned out to be that I attempted to
> allocate a 2MB array on the stack (I hadn't realized how big would
> turn out to be) 

The only problem with object composition is that egcs has some limit on
objects and their virtual function table implementation on large objects.
(I expect the compiler on some cases need to make extra pointers inside
the object to let parts of an object refer to other parts of the same
object... and guess those are done with some offsets - with limited
amount of bits... I think its something to do with virtual inheritance
support or something)

> ... once I changed this to dynamic allocation everything
> worked OK again ... while the individual Gtk-- objects may be small,
> I do this (stack allocation) all over the Gui which totals up to quite a lot
> of objects ...

allocating everything in stack has one bad consiquence - you will get
less memory protection, since they're all in continuous memory area
where the application has access to. Thus other parts of your program
might mess up (with pointer trickery and arrays) parts of the other
data. With dynamic mem allocation, there'll be spreaded some bytes in
address space which are protected - minor pointer errors gets revealed
much easier.

-- 
-- Tero Pulkkinen -- terop@modeemi.cs.tut.fi --



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]