[Bug go/72814] reflect FAILs on 32-bit Solaris/SPARC: SIGILL

2016-08-08 Thread ian at airs dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72814

Ian Lance Taylor  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #3 from Ian Lance Taylor  ---
Fixed.

[Bug go/72814] reflect FAILs on 32-bit Solaris/SPARC: SIGILL

2016-08-08 Thread ian at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72814

--- Comment #2 from ian at gcc dot gnu.org  ---
Author: ian
Date: Mon Aug  8 19:53:44 2016
New Revision: 239252

URL: https://gcc.gnu.org/viewcvs?rev=239252=gcc=rev
Log:
PR go/72814

runtime: treat zero-sized result value as void

Change the FFI interface to treat a call to a function that returns a
zero-sized result as a call to a function that returns void.

This is part of the fix for https://gcc.gnu.org/PR72814.  On 32-bit
SPARC systems, a call to a function that returns a non-zero-sized struct
is followed by an unimp instruction that describes the size of the
struct.  The function returns to the address after the unimp
instruction.  The libffi library can not represent a zero-sized struct,
so we wind up treating it as a 1-byte struct.  Thus in that case libffi
calls the function with an unimp instruction, but the function does not
adjust the return address.  The result is that the program attempts to
execute the unimp instruction, causing a crash.

This is part of a change that fixes the crash by treating all functions
that return zero bytes as functions that return void.

Reviewed-on: https://go-review.googlesource.com/25585

* go-gcc.cc (Gcc_backend::function_type): If the return type is
zero bytes, treat the function as returning void.
(return_statement): If the return type is zero bytes, don't
actually return any values.

Modified:
trunk/gcc/go/ChangeLog
trunk/gcc/go/go-gcc.cc
trunk/gcc/go/gofrontend/MERGE
trunk/libgo/runtime/go-ffi.c

[Bug go/72814] reflect FAILs on 32-bit Solaris/SPARC: SIGILL

2016-08-08 Thread ian at airs dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72814

Ian Lance Taylor  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2016-08-08
 Ever confirmed|0   |1

--- Comment #1 from Ian Lance Taylor  ---
The failing test is a function that returns a zero-sized struct.  The libffi
library does not support a zero-sized struct, so libgo and libffi togther wind
up treating the return type as a struct whose size is 1 byte.  On 32-bit SPARC,
a call to a function that returns a struct whose size is larger than 0 is
followed by an unimp instruction.  The function is compiled to skip the unimp
instruction when it returns.  See the handling of %) in sparc_print_operand in
gcc/config/sparc/sparc.c.  So libffi, thinking that the function returns a
non-empty struct, provides an unimp instruction to be skipped.  But the actual
function returns an empty struct, and therefore does not expect the unimp
instruction, and therefore does not skip it.  The result is an attempt to
execute the instruction, causing the SIGILL.

[Bug go/72814] reflect FAILs on 32-bit Solaris/SPARC: SIGILL

2016-08-05 Thread ro at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72814

Rainer Orth  changed:

   What|Removed |Added

   Target Milestone|--- |7.0