Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: BUG: useheap in doexpandhist()



On Jun 25,  2:01am, Zoltan Hidvegi wrote:
} Subject: Re: BUG: useheap in doexpandhist()
}
} The signal trap can leave the allocation in some undefined state.  My
} patch just makes sure that after executiong the trap the original
} allocation state is restored.

Hmm.  I understand the part about restoring the original state, but how
can the trap leave the allocation in an *undefined* state?  Seems to me
that if the trap doesn't always *leave* the allocation in the same state
(heap, it appears) then there's something more serious wrong.  It's the
state when you *start* handling the signal that is unknown (to the trap).

That means restoring state is the right thing to do regardless of other
reentrancy issues; but maybe it's doshfunc() that should be saving and
restoring the state, so that it's consistent everywhere doshfunc() is
called?

} I think that the heap used in zsh is very useful.  It is convinient, it
} certainly guarantees that there is no memory leak if the heap is used and
} it is efficient since instead of calling malloc()/free() frequently we call
} these only a few times.

Yes, the heap certainly guarantees that zsh's performance will be just
about the same no matter how well or poorly the underlying malloc works.
It also guarantees that if you accidentally allocate something on the
zsh heap that should have been on the "permanent" heap, zsh eventually
will dump core; and it almost guarantees that programmers will be sloppy
about freeing memory, because they assume the heap prevents leakage.

I apologize to members of the Paul Falstad Fan Club, but I think zsh
would have been a lot more reliable a whole lot sooner if he had never
used that trick.

-- 
Bart Schaefer                     Vice President, Technology, Z-Code Software
schaefer@xxxxxxxxxx                   Division of NetManage Corporation
http://www.well.com/www/barts           http://www.ncdsoft.com/ZMail/




Messages sorted by: Reverse Date, Date, Thread, Author