[m-rev.] for review: fix `mmc --make' signal bugs
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Nov 21 21:00:49 AEDT 2002
On 21-Nov-2002, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> On 21-Nov-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > That diff looks fine, but while reviewing it I spotted a bug
> > in the existing code that you were modifying:
> >
> > On 21-Nov-2002, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > >
> > > +++ compiler/process_util.m 21 Nov 2002 00:46:43 -0000
> > > @@ -193,7 +193,7 @@
> > >
> > > MR_incr_hp_msg(SigintHandler,
> > > MR_bytes_to_words(sizeof(MR_signal_action)),
> > > - MR_PROC_LABEL, ""make.util.signal_action/0"");
> > > + MR_PROC_LABEL, ""libs.process_util.signal_action/0"");
> >
> > There is no guarantee that the memory allocated by MR_incr_hp_msg()
> > will be sufficiently aligned to hold a value of type MR_signal_action.
>
> How aligned does it need to be?
That depends on the C implementation.
In practice I suspect that word alignment would be sufficient for most
implementations. But it's not guaranteed to work.
> runtime/mercury_heap.h contains the following code in
> MR_MAYBE_BOX_FOREIGN_TYPE.
>
> /* XXX this assumes that nothing requires */
> /* stricter alignment than MR_Float */
> MR_make_hp_float_aligned();
> MR_incr_hp(MR_LVALUE_CAST(MR_Word, (box)), size_in_words);
>
> Is putting a call to MR_make_hp_float_aligned() before the call
> to MR_incr_hp_msg() acceptable, or should I be using some other
> method to allocate the memory.
I'd be reluctant to duplicate that hack; it would be
be better to encapsulate it in a single routine
/* XXX this assumes that nothing requires */
/* stricter alignment than MR_Float */
#define MR_make_hp_fully_aligned() MR_make_hp_float_aligned()
so that the XXX can be fixed in one place later.
But an even better solution would be to use `pragma foreign_type'
for the signal action type. Then the Mercury compiler will
handle the necessary memory allocation automatically
(using MR_MAYBE_BOX_FOREIGN_TYPE()).
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list