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

Peter Wang novalazy at gmail.com
Wed Jun 5 18:02:20 AEST 2019


Some help with the log message would be appreciated. I don't know if
I've named the things correctly.

It seems more bugs like this could easily be lurking, but at least
there are no other failing tests (except for write_xml but I'm pretty
sure it's not a real failure).

----

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. When the vector is cast to
MR_TypeParamLocns_Struct, and the MR_tp_param_count field dereferenced,
only the lowest 32-bits are read. 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];
 };
 
-- 
2.21.0



More information about the reviews mailing list