pro64-support
[Top] [All Lists]

Re: segmentation fault

To: jonhsu@xxxxxxxxxxxxx
Subject: Re: segmentation fault
From: Robert Kennedy <robert@xxxxxxxxxxxxx>
Date: Mon, 14 May 2001 09:33:35 -0700
Cc: pro64-support@xxxxxxxxxxx
In-reply-to: <3AFC3E6D.31376E93@tensilica.com> (message from Jon Hsu on Fri, 11 May 2001 12:33:01 -0700)
References: <3AFC3E6D.31376E93@tensilica.com>
Sender: owner-pro64-support@xxxxxxxxxxx
> I believe I've found a bug in the implementation of
> RELATED_SEGMENTED_ARRAY.

Now that I've read your message more carefully, I believe the feature
under discussion is something that got added after I worked on the
RELATED_SEGMENTED_ARRAY template. So I am not much of an expert in
this area, but I think your suggested fix is a good one.

Conceptually, the decisions about who should free memory (in other
words, whether the template class's destructor should free the blocks)
should be made and recorded at the point where the template class
either receives a block from outside, or allocates a new block
itself. The fundamental reason for the problem you observed is that
someone tried to put this decision in two separate places (allocations
and intake of outside blocks are done in one place, while the flags
recording who owns the memory are recorded in another). Doing that is
almost always a bad idea because it's error prone, fragile, and hard
to understand.

Your suggestion is the easy way out; doing it right (now that it has
been done wrong) seems like it would take more work... That's why I
think it would be reasonable to implement your idea.

        -- Robert


<Prev in Thread] Current Thread [Next in Thread>