From: Petr P. <pp...@re...> - 2017-02-13 14:58:42
|
On Mon, Feb 13, 2017 at 02:53:07PM +0100, Petr Pisar wrote: > Hello, when building yap-6.2.2 with GCC 7, I obtain this build failure on i686 > only: [...] > Do you have any idea what's wrong? I guess GCC 7 brought some new > optimizations that leads to misbehaving code. > After compiling the code with -fsanitize=undefined compiler option, I can see these warnings: C/scanner.c:567:17: runtime error: signed integer overflow: 268435453 * 16 cannot be represented in type 'int' H/Yatom.h:161:39: runtime error: member access within misaligned address 0x1005c299 for type 'struct FunctorEntry', which requires 4 byte alignment H/Yatom.h:161:39: runtime error: member access within misaligned address 0x10120631 for type 'struct FunctorEntry', which requires 4 byte alignment H/Yatom.h:161:39: runtime error: member access within misaligned address 0x10120631 for type 'struct FunctorEntry', which requires 4 byte alignment H/Yatom.h:161:39: runtime error: member access within misaligned address 0x10120631 for type 'struct FunctorEntry', which requires 4 byte alignment H/Yatom.h:161:39: runtime error: member access within misaligned address 0x10120631 for type 'struct FunctorEntry', which requires 4 byte alignment H/Yatom.h:161:39: runtime error: member access within misaligned address 0x10120631 for type 'struct FunctorEntry', which requires 4 byte alignment H/Yatom.h:161:39: runtime error: member access within misaligned address 0x10120631 for type 'struct FunctorEntry', which requires 4 byte alignment H/Yatom.h:161:39: runtime error: member access within misaligned address 0x10120631 for type 'struct FunctorEntry', which requires 4 byte alignment H/Yatom.h:161:39: runtime error: member access within misaligned address 0x10063889 for type 'struct FunctorEntry', which requires 4 byte alignment H/Yatom.h:161:39: runtime error: member access within misaligned address 0x10063889 for type 'struct FunctorEntry', which requires 4 byte alignment H/Yatom.h:161:39: runtime error: member access within misaligned address 0x10063889 for type 'struct FunctorEntry', which requires 4 byte alignment C/absmi.c:12286:4: runtime error: member access within misaligned address 0x101e6e52 for type 'struct yami', which requires 4 byte alignment Because i686 allows unaliagned access, I think a problem could be the signed integer overflow in get_num() at C/scanner.c:567: Int val = 0L; [...] } else if (ch == 'x' && base == 0) { might_be_float = FALSE; if (--max_size == 0) { Yap_ErrorMessage = "Number Too Long"; return TermNil; } *sp++ = ch; ch = Nxtch(inp_stream); while (my_isxdigit(ch, 'F', 'f')) { Int oval = val; int chval = (chtype(ch) == NU ? ch - '0' : (my_isupper(ch) ? ch - 'A' : ch - 'a') + 10); if (--max_size == 0) { Yap_ErrorMessage = "Number Too Long"; return TermNil; } *sp++ = ch; → val = val * 16 + chval; if (oval != (val-chval)/16) /* overflow */ has_overflow = TRUE; ch = Nxtch(inp_stream); } *chp = ch; } -- Petr |