Thanks for catching that.

I don't have access to test machines, but could you possibly try the
attached patch?

Thanks, Than



On Thu, May 3, 2018 at 3:03 PM Rainer Orth <r...@cebitec.uni-bielefeld.de>
wrote:

> Hi Ian,

> > This patch by Than McIntosh breaks the dependence of go-unwind.c on
> > unwind-pe.h, by adding the required definitions and code directly to
> > go-unwind.c.  go-unwind.c still depends on the public unwind.h API.
> > This makes it easier to build libgo separately.  Bootstrapped and ran
> > Go testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

> I strongly suspect that this patch severely broke Go on Solaris/SPARC:
> between 20180502 (r259840) and 20180503 (r259897) there appeared tons of
> new execution failures, both 32 and 64-bit:

> +FAIL: go.go-torture/execute/printnil.go execution,  -O0
> +FAIL: go.go-torture/execute/printnil.go execution,  -O1
> +FAIL: go.go-torture/execute/printnil.go execution,  -O2
> +FAIL: go.go-torture/execute/printnil.go execution,  -O2 -fbounds-check
> +FAIL: go.go-torture/execute/printnil.go execution,  -O2
-fomit-frame-pointer -finline-functions
> +FAIL: go.go-torture/execute/printnil.go execution,  -O2
-fomit-frame-pointer -finline-functions -funroll-loops
> +FAIL: go.go-torture/execute/printnil.go execution,  -O3 -g
> +FAIL: go.go-torture/execute/printnil.go execution,  -Os

> and many more, also in libgo and gotools tests.

> One example is printnil.x:

> Thread 9 received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 4 (LWP 4)]
> read_encoded_value (val=<synthetic pointer>, p=0xfebcb953 "",
>      encoding=3 '\003', context=0x0)
>      at /vol/gcc/src/hg/trunk/local/libgo/runtime/go-unwind.c:250
> 250                 decoded = (_Unwind_Internal_Ptr)(*(const void *const
*)p);
> (gdb) where
> #0  read_encoded_value (val=<synthetic pointer>, p=0xfebcb953 "",
>      encoding=3 '\003', context=0x0)
>      at /vol/gcc/src/hg/trunk/local/libgo/runtime/go-unwind.c:250
> #1  __gccgo_personality_v0 (version=<optimized out>, actions=1,
>      exception_class=<optimized out>, ue_header=0x1cc44000,
context=0x105810ec)
>      at /vol/gcc/src/hg/trunk/local/libgo/runtime/go-unwind.c:472
> #2  0xfefbd450 in _Unwind_RaiseException (exc=0x1cc44000)
>      at
/builds2/ulhg/workspace/Solaris_Trunk/Userland/full-build/02b-build-sparc/components/gcc7/gcc-7.3.0/libgcc/unwind.inc:113
> #3  0xfe59fb00 in runtime.throwException ()
>      at /vol/gcc/src/hg/trunk/local/libgo/runtime/go-unwind.c:124
> #4  0xfe9e5a90 in runtime.unwindStack ()
>      at /vol/gcc/src/hg/trunk/local/libgo/go/runtime/panic.go:336
> #5  runtime.gopanic (e=...)
>      at /vol/gcc/src/hg/trunk/local/libgo/go/runtime/panic.go:527
> #6  0xfe5a0758 in runtime_panicstring (s=0xfe3e32d8 "nil pointer
dereference")
>      at /vol/gcc/src/hg/trunk/local/libgo/runtime/panic.c:38
> #7  0xfe59f65c in __go_runtime_error (i=<optimized out>)
>      at /vol/gcc/src/hg/trunk/local/libgo/runtime/go-runtime-error.c:76
> #8  0x000120b4 in main.MyType.String ()
>      at
/vol/gcc/src/hg/trunk/local/gcc/testsuite/go.go-torture/execute/printnil.go:11
> #9  0xfe6efa08 in fmt.pp.handleMethods (p=0x10bf4000, verb=115)
>      at /vol/gcc/src/hg/trunk/local/libgo/go/fmt/print.go:603
> #10 0xfe6eebdc in fmt.pp.printArg (p=0x10bf4000, arg=..., verb=115)
>      at /vol/gcc/src/hg/trunk/local/libgo/go/fmt/print.go:686
> #11 0xfe6f0d84 in fmt.pp.doPrintf (p=0x10bf4000, format=..., a=...)
>      at /vol/gcc/src/hg/trunk/local/libgo/go/fmt/print.go:1003
> #12 0xfe6f1460 in fmt.Sprintf (format=..., a=...)
>      at /vol/gcc/src/hg/trunk/local/libgo/go/fmt/print.go:203
> #13 0x000121e0 in main.main ()
>      at
/vol/gcc/src/hg/trunk/local/gcc/testsuite/go.go-torture/execute/printnil.go:16

> Seems like the new code doesn't play well on strict-alignment targets.

>          Rainer

> --

-----------------------------------------------------------------------------
> Rainer Orth, Center for Biotechnology, Bielefeld University
diff --git a/libgo/runtime/go-unwind.c b/libgo/runtime/go-unwind.c
index 536a619d..6464bec7 100644
--- a/libgo/runtime/go-unwind.c
+++ b/libgo/runtime/go-unwind.c
@@ -247,7 +247,7 @@ read_encoded_value (struct _Unwind_Context *context, 
uint8_t encoding,
               break;
             }
           case DW_EH_PE_absptr:
-            decoded = (_Unwind_Internal_Ptr)(*(const void *const *)p);
+            __builtin_memcpy (&decoded, (const void *)p, sizeof(const void*));
             p += sizeof(void *);
             break;
           default:

Reply via email to