2024-11-22 00:28 AEDT

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000454mercuryBugpublic2018-03-13 14:19
Reporterwangp 
Assigned Towangp 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000454: arith_int64 failure
Descriptionarith_int64 fails on Ubuntu 16.04 x86_64
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)
Mercury rotd 2018-03-07

--- arith_int64.out 2018-03-09 16:23:20.780057386 +1100
+++ arith_int64.exp 2018-02-03 23:05:01.000000000 +1100
@@ -17,20 +17,20 @@
 
 *** Test unary operation '-' ***
 
-- -9223372036854775808 = -9223372036841988320
-- -2147483648 = 2160271136
-- -64768 = 12852256
-- -128 = 12787616
-- 0 = 12787488
-- 1 = 12787487
-- 2 = 12787486
-- 8 = 12787480
-- 10 = 12787478
-- 16 = 12787472
-- 127 = 12787361
-- 64767 = 12722721
-- 2147483647 = -2134696159
-- 9223372036854775807 = -9223372036841988319
+- -9223372036854775808 = -9223372036854775808
+- -2147483648 = 2147483648
+- -64768 = 64768
+- -128 = 128
+- 0 = 0
+- 1 = -1
+- 2 = -2
+- 8 = -8
+- 10 = -10
+- 16 = -16
+- 127 = -127
+- 64767 = -64767
+- 2147483647 = -2147483647
+- 9223372036854775807 = -9223372036854775807
 
 *** Test unary operation 'abs' ***
 
@@ -56,15 +56,15 @@
 nabs -64768 = -64768
 nabs -128 = -128
 nabs 0 = 0
-nabs 1 = 12787487
-nabs 2 = 12787486
-nabs 8 = 12787480
-nabs 10 = 12787478
-nabs 16 = 12787472
-nabs 127 = 12787361
-nabs 64767 = 12722721
-nabs 2147483647 = -2134696159
-nabs 9223372036854775807 = -9223372036841988319
+nabs 1 = -1
+nabs 2 = -2
+nabs 8 = -8
+nabs 10 = -10
+nabs 16 = -16
+nabs 127 = -127
+nabs 64767 = -64767
+nabs 2147483647 = -2147483647
+nabs 9223372036854775807 = -9223372036854775807
 
 *** Test binary operation '+' ***
 
TagsNo tags attached.
Attached Files

-Relationships
+Relationships

-Notes

~0000968

wangp (developer)

For this program:

main(!IO) :-
    X = 1i64,
    Y = -X,
    write_int64(Y, !IO),
    nl(!IO).

the compiler is producing:

void MR_CALL
main_2_p_0(void)
{
  {
    int64_t X_4 = INT64_C(1);
    int64_t Y_5 = (INT64_C(12789120) - X_4);

    mercury__io__write_int64_3_p_0(Y_5);
    mercury__io__nl_2_p_0();
  }
}

~0000970

wangp (developer)

The problem is with a compiler in the .pregen grade.

~0000971

wangp (developer)

Ok, it's to do with (un)boxed int64s in a static ground term, see sgt_int64.m.

~0000972

zs (developer)

I have noticed that both unify_gen.m and ml_unify_gen.m still retain
in most of their code the assumption that every argument of a functor
occupies exactly one word in the memory cell. There are places that
do deal with floats that take up double words and places that deal
with two or more enum fields being packed into the same word,
but they are post-processing the output of a word-oriented computation.

I have started changing this over the last week or so, and will continue
working on it, since doing so is prerequisite for improving argument packing.
I think it very likely that this work will fix this bug.

~0000973

zs (developer)

The attached program, bar_baz.m, has code to allocate
both a 64 bit float and a 64 bit integer both dynamically and statically.
In pregen grades, all four allocations are boxed. This suggests to me
that the bug is not in the allocation code, but I cannot check it
since I don't have a 32 bit system. Can someone else who does
try out this program (compiled with --no-inlining)?
Maybe you could also check whether doing a deconstruct
does the right thing for all of FX, FY, IX and IY, since deconstruct
has special code (MR_arg_value_uncommon) for 64 bit floats
but not for 64 bit ints.

~0000974

wangp (developer)

The problem is that MR_BOXED_INT64S should be defined in .pregen grades (whether or not we are on a 32-bit or 64-bit machine). I will run a bootcheck then send a patch.

~0000975

wangp (developer)

Fixed in commit b58cc673e
+Notes

-Issue History
Date Modified Username Field Change
2018-03-09 16:25 wangp New Issue
2018-03-09 16:56 wangp Note Added: 0000968
2018-03-09 17:57 wangp Note Added: 0000970
2018-03-09 18:02 wangp File Added: sgt_int64.m
2018-03-09 18:04 wangp Note Added: 0000971
2018-03-09 20:52 zs Note Added: 0000972
2018-03-09 20:52 zs Assigned To => zs
2018-03-09 20:52 zs Status new => assigned
2018-03-13 06:14 zs File Added: bar_baz.m
2018-03-13 06:14 zs Note Added: 0000973
2018-03-13 11:21 wangp Note Added: 0000974
2018-03-13 14:19 wangp Assigned To zs => wangp
2018-03-13 14:19 wangp Status assigned => resolved
2018-03-13 14:19 wangp Resolution open => fixed
2018-03-13 14:19 wangp Note Added: 0000975
+Issue History