From owner-freebsd-amd64@FreeBSD.ORG Wed May 28 22:56:08 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 7C0F1B01 for ; Wed, 28 May 2014 22:56:08 +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 2A33E2EBB for ; Wed, 28 May 2014 22:56:07 +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 s4SMtaRR017520 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 29 May 2014 08:55:41 +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 s4SMthns053812 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 29 May 2014 08:55:43 +1000 (EST) (envelope-from peter@server.rulingia.com) Received: (from peter@localhost) by server.rulingia.com (8.14.8/8.14.8/Submit) id s4SMtguE053811; Thu, 29 May 2014 08:55:42 +1000 (EST) (envelope-from peter) Date: Thu, 29 May 2014 08:55:42 +1000 From: Peter Jeremy To: Konstantin Belousov Subject: Re: i386 Go programs crash on amd64 Message-ID: <20140528225542.GA46230@server.rulingia.com> References: <20140523225300.GA14433@server.rulingia.com> <537FD853.3000505@wemm.org> <537FD9A2.2010607@wemm.org> <20140523233444.GH74331@kib.kiev.ua> <20140524033944.GA96083@server.rulingia.com> <20140524074101.GI74331@kib.kiev.ua> <20140526113622.GB96083@server.rulingia.com> <20140526134457.GR74331@kib.kiev.ua> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="5mCyUwZo2JvN/JJP" Content-Disposition: inline In-Reply-To: <20140526134457.GR74331@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: Wed, 28 May 2014 22:56:08 -0000 --5mCyUwZo2JvN/JJP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2014-May-26 16:44:57 +0300, Konstantin Belousov wr= ote: >On Mon, May 26, 2014 at 09:36:22PM +1000, Peter Jeremy wrote: >> On 2014-May-24 10:41:01 +0300, Konstantin Belousov = wrote: >> >> >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. >>=20 >> Actually, I've found that >> -------- >> package main >> import "syscall" >> func main() { syscall.Write(1, []byte("Hello World\n")) } >> -------- >> also crashes ~66 syscalls after the first sysarch(2) call. That >> reduces the binary to 520K (go reports this is 50K lines of assembler). >>=20 >> >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). >>=20 >> I've uploaded the source, binary and disassembly to >> freefall:~peterj/write{.go,,.S} (and verified it crashes). >>=20 >> If I get time, I'll see if I can strip some of the support code out of >> Go to shrink it further. > >What exactly do you mean by 'crashing' ? I see it dying with either SIGBUS or SIGSEGV. On freefall, I see: freefall% ./write=20 zsh: segmentation fault (core dumped) ./write > I see some spills from (probably) Go runtime. I've tried further experiments with different hardware and different loading and get different results: Sometimes I get nothing other than a coredump and an other times I get part or all of a runtime spill similar to you. I suspect there may be multiple issues. > I am not sure that this is something which should >be looked at from the kernel side, at least initially. As I wrote in my initial mail, I am not certain whether this is a problem with Go or FreeBSD. And having done some poking at corefiles with gdb (you need gdb7.6 from ports to grok the Go debug information), I have found that all my programs are dying at: mov %gs:0xfffffff8,%ecx but it seems to be timing related as to when the offending instruction is executed. I will do some further investigation into how segment wraparound is handled. > E.g., the 32bit >binaries on amd64 have stack starting near the top of the address space, >i.e. 4G - some amount. Could this be a problem for the Go ? That seems unlikely but I guess it's a possibility. --=20 Peter Jeremy --5mCyUwZo2JvN/JJP Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iQJ8BAEBCgBmBQJThmluXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRFRUIyOTg2QzMwNjcxRTc0RTY1QzIyN0Ux NkE1OTdBMEU0QTIwQjM0AAoJEBall6Dkogs06PEP/RfJgCzPesp03/LGb0EFCZzi cvvikhrOlrLr1xMX43zinRsnEvB4jxItLTPzMfLiGLo0nUl1RZPlxG8Ta2UaNu9n QD8Wjcuau1AigtF5W9DaE3oqed98mLSsCCvsuWc2iKx/CWCoHJawgbmEugvaekEZ kniiw2y/2Vxtx2AdkSCozHpqmsVrQr1gvPBSp8H5UN27eFgEY+DSTWRP4bUGDyPc BohvumUdJ+F1naujpSf1WX5T8oLElAiUhUuZNZI2Cy9Y2VJpVpc936ibzAYRd795 i1exWDvrqBlKm2hiif+YR1ECsSYZvD1b4AxZOTn2btEYSxczEjQfvBYS+YETTUQX rQ0iSrdiE7Rsm4lom4+039NDwGwY/L98DClN53ItF6S1jAVQfc4N6hg7AZ8WzSEj Ujv2Gci27x7X2q64RVEOx1P8e9LREKZtTRvGv9hcOWRiyZje3d58k1AE7/MdIyTV rGFjlXJLlWHhvNnemnA6qaNxRgo/VR+zNoYmdhUn0m1aLhdL+DDhkRPwoXIOt3Ym r8XMI3dKPwqJ9HIReJxFVn5b7TvOakOCt559c+CpQlZQ0ZRT1Ztnp01RNiG06wh8 29H2q8i6A0OsDA89qcsi31RJUCpXKPJqClDB3xYYww5DDCu+dG99mjJCay4ixBx1 9iBuGhV33HQmQGsREa9Q =D+nb -----END PGP SIGNATURE----- --5mCyUwZo2JvN/JJP--