[gofrontend-dev] Re: [PATCH 00/13] Go closures, libffi, and the static chain

Dominik Vogt vogt@linux.vnet.ibm.com
Fri Dec 12 12:06:00 GMT 2014


On Thu, Dec 11, 2014 at 11:56:00AM -0800, Richard Henderson wrote:
> On 12/11/2014 04:25 AM, Dominik Vogt wrote:
> > Update:  If I disable the custom s390x code and switch to the
> > implementation just using libffi for reflection calls, the same
> > crash occurs with the testing/quick libgo test case.  The called
> > function sees a bogus value written by the synamic linker as the
> > closure pointer, for example with this line in the test code:
> > 
> >   CheckEqual(fComplex64, fComplex64, nil)

>  Is the s390 port somehow putting the address of a plt entry here?

Digging through the test program with the debugger reveals that
the register corruption is not caused by dynamic linking.
Instead, libgo lacks a patch that is necessary for complex
support.  Without that, ffi_prep_args treats _Complex like a
struct with two elements (which it is not on s390[x]) and messes
up the layout of the stack arguments, eventually loading the wrong
values into the registers when the test function is called.  It
turns out that the bad value in r0 was just a red herring in this
case.

I'm not sure I've posted the missing patch anywhere yet, so it's
attached to this message.  At the moment it enables
FFI_TYPE_COMPLEX only for s390[x], but eventually this should be
used unconditionally.

--

(This still leaves the dynamic linking issue if we do not use
libffi for reflection calls with x86* and s390[x].  Is the plan to
remove the platform specific abi code for the few platforms that
have it?  I see no way to make them work with the static chain
patch anyway.)

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-libgo-Enable-complex-number-support-from-libffi.patch
Type: text/x-diff
Size: 2433 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20141212/67de7760/attachment.bin>


More information about the Gcc-patches mailing list