From owner-freebsd-amd64@FreeBSD.ORG Sat May 24 03:40:10 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 F35FCABB for ; Sat, 24 May 2014 03:40:09 +0000 (UTC) Received: from vps.rulingia.com (vps.rulingia.com [103.243.244.15]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "vps.rulingia.com", Issuer "CAcert Class 3 Root" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id A37AA22DD for ; Sat, 24 May 2014 03:40:08 +0000 (UTC) Received: from server.rulingia.com (c220-239-242-83.belrs5.nsw.optusnet.com.au [220.239.242.83]) by vps.rulingia.com (8.14.7/8.14.7) with ESMTP id s4O3dgtr074899 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 24 May 2014 13:39:47 +1000 (EST) (envelope-from peter@rulingia.com) X-Bogosity: Ham, spamicity=0.000000 Received: from server.rulingia.com (localhost.rulingia.com [127.0.0.1]) by server.rulingia.com (8.14.8/8.14.8) with ESMTP id s4O3djqD017317 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 24 May 2014 13:39:45 +1000 (EST) (envelope-from peter@server.rulingia.com) Received: (from peter@localhost) by server.rulingia.com (8.14.8/8.14.8/Submit) id s4O3diX0017316; Sat, 24 May 2014 13:39:44 +1000 (EST) (envelope-from peter) Date: Sat, 24 May 2014 13:39:44 +1000 From: Peter Jeremy To: Konstantin Belousov Subject: Re: i386 Go programs crash on amd64 Message-ID: <20140524033944.GA96083@server.rulingia.com> References: <20140523225300.GA14433@server.rulingia.com> <537FD853.3000505@wemm.org> <537FD9A2.2010607@wemm.org> <20140523233444.GH74331@kib.kiev.ua> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="envbJBWh7q8WU6mo" Content-Disposition: inline In-Reply-To: <20140523233444.GH74331@kib.kiev.ua> X-PGP-Key: http://www.rulingia.com/keys/peter.pgp User-Agent: Mutt/1.5.23 (2014-03-12) 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 03:40:10 -0000 --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 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--