From owner-freebsd-amd64@FreeBSD.ORG Sat May 24 07:41:15 2014 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6E680A54 for ; Sat, 24 May 2014 07:41:15 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E9EB523BF for ; Sat, 24 May 2014 07:41:14 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.8/8.14.8) with ESMTP id s4O7f402063504; Sat, 24 May 2014 10:41:04 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.3 kib.kiev.ua s4O7f402063504 Received: (from kostik@localhost) by tom.home (8.14.8/8.14.8/Submit) id s4O7f1rM063493; Sat, 24 May 2014 10:41:01 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 24 May 2014 10:41:01 +0300 From: Konstantin Belousov To: Peter Jeremy Subject: Re: i386 Go programs crash on amd64 Message-ID: <20140524074101.GI74331@kib.kiev.ua> References: <20140523225300.GA14433@server.rulingia.com> <537FD853.3000505@wemm.org> <537FD9A2.2010607@wemm.org> <20140523233444.GH74331@kib.kiev.ua> <20140524033944.GA96083@server.rulingia.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Xdd9Z8fLQ2awL3hZ" Content-Disposition: inline In-Reply-To: <20140524033944.GA96083@server.rulingia.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: freebsd-amd64@freebsd.org X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 May 2014 07:41:15 -0000 --Xdd9Z8fLQ2awL3hZ Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, May 24, 2014 at 01:39:44PM +1000, Peter Jeremy wrote: > On 2014-May-24 02:34:44 +0300, Konstantin Belousov = wrote: > >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 d= own > >> >> 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_= ldt() > >> >> and the i386_set_ldt() emulation in the amd64 kernel matches the i3= 86 > >> >> kernel - but the net result doesn't work. > >> >> > >> >> Can anyone offer any suggestions as to how to resolve this? > >Provide the minimal test case. >=20 > The following go program, compiled on i386 and run on amd64 will die > with a segmentation violation or bus error: > ------- > package main >=20 > import "fmt" >=20 > func main() { > fmt.Println("Hello World") > } > ------- No, this is not consumable. I need a self-contained minimal example written in C/asm. If this is too hard to produce, give the the self-contained binary, again as small as possible (small by comparing the number of syscalls before the issue manifests itself). As the absolute minimum I could start with the output on ctty with machdep.uprintf_signal=3D1, but it is only for beginning. >=20 > >> >> > >> > 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 iss= ue=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. >=20 > As installed, the code is in /usr/local/go/src/pkg/runtime/sys_freebsd_38= 6.s > "runtime=9Esetldt", which calls "runtime=9Ei386_set_ldt" which uses "int = 128". >=20 > >We do support ldt for 32bit binaries on amd64. >=20 > I thought it was supported. >=20 > --=20 > Peter Jeremy --Xdd9Z8fLQ2awL3hZ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iQIcBAEBAgAGBQJTgE0NAAoJEJDCuSvBvK1BR5oQAIWy6L9Iiy6u2yypGIaZy9rs y0p4vgbnCvdEJ4t+J87R2EltywRTkgxvkmNDjwzW+mTpdGNnruHxi9ZDHCltYDe0 OsnKnxVDIsFfGXicszc2fCpcBJ+Ga8XJBBr0/cyodOIKdoffPn8+cYG4h5qZTCF/ z7JGMcxOcspCTSZVwC8rB78PoT1NaUh7DiCYg8QsVWMyxEMACR1g4MeeghT1L84Z GEjMgmATRrbIK3p+OufGAKjysIuaroneJGqy5noWo2OA5MD6rw0ISCcwimDAGU7/ CvairxUsTQHo66rKorJ+FPw9lLOGPuv6P9Cm3cUuHKqjeXIM19S1E8xAWTpZ4Z+F 8PACveSXREA0WOPi4TIvTqX8X93x0uSlFDjSWG3KOPfQgMvbvgMl6g2yMOy7cgxr VnyZmjJA3BtYxh2/125vIJrcOHBdM3IlI05YEY24rVoy0cp7RkSrl/KUFKb16sLP XPjEJimW+fIwMrwNdfJ/x77T51Y8kb4OniDRwEVQse9ex7IC1d4TnLu0k2PXfov4 rR02vEr9Vtg0dRT5bcKfVEO83GJ5TSlCc1i40WdXcKI0c/YBz4gdBgx0zqcaS3Pv 1eF+Ady0/x/LQ+zj5kLmeGjqGCP/DQg4RaWgMtYbJnS3O5DEkvctvLFm/J1CzOS7 87AtDROdmBx4qTGtSFR6 =FDOV -----END PGP SIGNATURE----- --Xdd9Z8fLQ2awL3hZ--