Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 May 2014 13:39:44 +1000
From:      Peter Jeremy <peter@rulingia.com>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        freebsd-amd64@freebsd.org
Subject:   Re: i386 Go programs crash on amd64
Message-ID:  <20140524033944.GA96083@server.rulingia.com>
In-Reply-To: <20140523233444.GH74331@kib.kiev.ua>
References:  <20140523225300.GA14433@server.rulingia.com> <537FD853.3000505@wemm.org> <537FD9A2.2010607@wemm.org> <20140523233444.GH74331@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

--envbJBWh7q8WU6mo
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On 2014-May-24 02:34:44 +0300, Konstantin Belousov <kostikbel@gmail.com> wr=
ote:
>On Fri, May 23, 2014 at 04:28:34PM -0700, Peter Wemm wrote:
>> On 5/23/14, 4:22 PM, Peter Wemm wrote:
>> > On 5/23/14, 3:53 PM, Peter Jeremy wrote:
>> >> I've been playing with Go (lang/go) and found that i386 Go binaries
>> >> segfault when run on amd64 (9.x, 10.x or HEAD).  I've narrowed it down
>> >> to the LDT handling but am not sure whether it's on the FreeBSD or Go
>> >> side.
>> >>
>> >> As far as I can see, the i386 binary is correctly calling i386_set_ld=
t()
>> >> and the i386_set_ldt() emulation in the amd64 kernel matches the i386
>> >> kernel - but the net result doesn't work.
>> >>
>> >> Can anyone offer any suggestions as to how to resolve this?
>Provide the minimal test case.

The following go program, compiled on i386 and run on amd64 will die
with a segmentation violation or bus error:
-------
package main

import "fmt"

func main() {
        fmt.Println("Hello World")
}
-------

>> >>
>> > We don't emulate i386_set_ldt().
>> >
>> > The 32 bit version of libc on amd64 has a different implementation=20
>> > that calls sysarch(I386_SET_FSBASE, ..) and friends.  Normally this is=
=20
>> > handled transparently by static linking, but obviously that's an issue=
=20
>> > for Go.
>>=20
>> Actually, that's an even more interesting question. WHY are they using=
=20
>> i386_set_ldt()?  Where is it coming from? As near as I can tell, libc,=
=20
>> libthr etc call I386_SET_GSBASE for tls.

As installed, the code is in /usr/local/go/src/pkg/runtime/sys_freebsd_386.s
"runtime=B7setldt", which calls "runtime=B7i386_set_ldt" which uses "int 12=
8".

>We do support ldt for 32bit binaries on amd64.

I thought it was supported.

--=20
Peter Jeremy

--envbJBWh7q8WU6mo
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (FreeBSD)

iQJ8BAEBCgBmBQJTgBSAXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRFRUIyOTg2QzMwNjcxRTc0RTY1QzIyN0Ux
NkE1OTdBMEU0QTIwQjM0AAoJEBall6Dkogs0RgMP/i6DVAQOasVS0zfD6Zpfa/Q7
bNaClDsML4G6KuhgS1Ir9IVBuuUPvP3YlDOLby0pJEOx+GmKjCI13QLV0et9p2YW
52dErqaKa9tLi4OhREXNs/7qu1rNppJdTJ3xusXQjk/reUW8bQgEOrd1esGVepa/
hAEWP4ubNg1IgvUdFLSaAyR7SG/kvzhdK3r9g1YOVPX4DyPQPOp24sL28XuveWVU
mFbCbu5cum4fSxP3ViYXQdJJj6z8ZwMTyNpLnyaNTFBzOZ7nib2O8kKI/tsDzKxI
/bIJKr7j1ExfUbGatDtLaokLnpWD3fYxFTK36jBLl7QNTidqnuXdHrRfcqNPk/R4
t3vfCMzZFeztFR8K5KZ5VqUrf1oxMtC5LWieMl/JP5y5ugYyzfueEWpmBqIBoXO8
niR/5NX8fazIjFj87U+19tQndcWMI/eutxt5MH4NuwLVXRm+UNxDa3p05mK8vH05
8NOIZAoHDCJ6b6JcGNDb1dCJMYaFRMd4yKZxyauqv2iZWUK6nDn7iU4ykevxCLgq
InMVP5zaMTe7h2djolWJLLvYdPPq6IauUN8e0a804GxL86oENxEF6deJNjKQppwD
mGDK+xnurQWXIjclYG/py2ofzhc1ZGFOzE3ZnoLnbvyKEgnStK5rj9QQjUpG7Ml4
BSnpAzC9F02o9bms9xLj
=Ho5H
-----END PGP SIGNATURE-----

--envbJBWh7q8WU6mo--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140524033944.GA96083>