https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93808

--- Comment #29 from John Paul Adrian Glaubitz <glaubitz at physik dot 
fu-berlin.de> ---
(In reply to John Paul Adrian Glaubitz from comment #28)
> Adrian, could please apply the following patch to the original string.c file
> and try building & running the whole thing again with the original compiler
> flags, with -fno-cross-jumping and with -O1.  Does one of the added traps go
> off?
> 
> 
> --- "orig ng/string.c.orig"   2019-10-01 20:02:30.000000000 +0900
> +++ "orig ng/string.c"        2020-02-22 18:29:54.904783490 +0900
> @@ -446,13 +446,15 @@
>  # define NONASCII_MASK 0x80808080UL
>  #endif
>  
> +if ( (intptr_t)(e-p) < 0) __builtin_trap ();
> +
>      if (UNALIGNED_WORD_ACCESS || e - p >= SIZEOF_VOIDP) {
>  #if !UNALIGNED_WORD_ACCESS
>       if ((uintptr_t)p % SIZEOF_VOIDP) {
>           int l = SIZEOF_VOIDP - (uintptr_t)p % SIZEOF_VOIDP;
>           p += l;
>           switch (l) {
> -           default: UNREACHABLE;
> +           default: __builtin_trap ();
>  #if SIZEOF_VOIDP > 4
>             case 7: if (p[-7]&0x80) return p-7;
>             case 6: if (p[-6]&0x80) return p-6;
> @@ -481,7 +483,7 @@
>      }
>  
>      switch (e - p) {
> -      default: UNREACHABLE;
> +      default: __builtin_trap ();
>  #if SIZEOF_VOIDP > 4
>        case 7: if (e[-7]&0x80) return e-7;
>        case 6: if (e[-6]&0x80) return e-6;

I did not see any of the traps fire. With the patch applied, it builds fine and
the Ruby interpreter doesn't crash. I'll attach the full build log.

Without the patch, Ruby crashes, even with the latest gcc-10 version (didn't
test gcc-11 yet as gcc-10 is currently the default for Debian unstable).

Reply via email to