[m-rev.] for review: Fix inconsistency in type parameter layout structures.

Zoltan Somogyi zoltan.somogyi at runbox.com
Wed Jun 5 20:29:39 AEST 2019



On Wed,  5 Jun 2019 18:02:20 +1000, Peter Wang <novalazy at gmail.com> wrote:
> Some help with the log message would be appreciated. I don't know if
> I've named the things correctly.

I am the person you need, since I wrote that code.

> The MR_TypeParamLocns_Struct field MR_tp_param_count has type
> MR_uint_least32_t, but the compiler generates type var vectors (???)
> in which every value is word sized.

I am not sure which vector you are talking about; there are so many
in the debugger RTTI. Is it the MR_tp_param_locns field that immediately
follows the count? If so, that doesn't hold type vars; it holds descriptions
of the locations in which the debugger can find the typeinfos describing
the types that are *bound* to those type vars.

> When the vector is cast to
> MR_TypeParamLocns_Struct, and the MR_tp_param_count field dereferenced,
> only the lowest 32-bits are read.

What code is this referring to?

> On 32-bit or little endian 64-bit
> machines the value will happen to be correct, but on big endian machines
> the value will be zero.
> 
> This bug caused hard_coded/copy_pred_2.m to fail on a 64-bit big endian
> machine (AIX/PowerPC).
> 
> runtime/mercury_stack_layout.h:
>     Change type of MR_tp_param_count to MR_Integer.
> 
> diff --git a/runtime/mercury_stack_layout.h b/runtime/mercury_stack_layout.h
> index 3e26e4877..627d30fbd 100644
> --- a/runtime/mercury_stack_layout.h
> +++ b/runtime/mercury_stack_layout.h
> @@ -476,7 +476,7 @@ struct MR_UserEventSpec_Struct {
>  #define MR_NOT_HIDDEN   0
>  
>  struct MR_TypeParamLocns_Struct {
> -    MR_uint_least32_t       MR_tp_param_count;
> +    MR_Integer              MR_tp_param_count;
>      MR_LongLval             MR_tp_param_locns[MR_VARIABLE_SIZED];
>  };

I think the right change is to MR_Unsigned, not MR_Integer.

Zoltan.


More information about the reviews mailing list