Re: [gtk-list] Re: Gtk--: Tracking down clobbered pointers and mysteriouscrashes
- From: Erik Mouw <J A K Mouw its tudelft nl>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: Gtk--: Tracking down clobbered pointers and mysteriouscrashes
- Date: Tue, 25 May 99 15:48:58 +0200
On Fri, 21 May 1999 19:51:30 +0300, gtk-list@redhat.com (Tero Pulkkinen) wrote:
> robert_gasch@peoplesoft.com writes:
>> 1) Does anybody have any suggestions for some (software)
>> tools which might aid in discovering these obsucre bugs?
>
> There's easy solution. Avoid pointers. :)
I wouldn't call that a solution. It's more the creation of another
problem.
> dynamic allocation in c++ is always a source of possible errors and
> c++ does support scopes really nicely. Almost all c++ features are
> geared towards not using dynamic mem. See where Multiple inheritance
> becomes useful, or object composition, or even slicing! - They're all
> there to support programming style that tries to avoid dynamic memory
> allocation and tries to do things by combining those tiny objects to
> larger units - and then do dynamic allocation only to those larger
> blocks.
I don't agree. Multiple inheritance can be useful with both static and
dynamic allocation. The C++ bible (Stroustrup's "The C++ programming
language") contains enough evidence.
The reason dynamic allocation is a source of errors is because you have to
be very careful with the pointers. C and C++ don't do bound checking like
Pascal does, so if you're messing outside the allocated region of an
object you won't get an exception. Well, you might get one, but it is very
well possible that it is in no way related with the currently executed
code. No bound checking does speed up things, but at a price: the
programmer (and not the compiler) is responsible for proper pointer
dealing.
You can get bound checking with a special memory allocator (at the price
of slower excecution). Only problem is that AFAIK there are only C memory
allocators (dmalloc, efence). I have heard rumours about a bound checking
version of gcc, but I can't remember where (maybe egcs or BugTraq).
Erik
--
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands
Phone: +31-15-2785859 Fax: +31-15-2781843 Email J.A.K.Mouw@its.tudelft.nl
WWW: http://www-ict.its.tudelft.nl/~erik/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]