From owner-freebsd-amd64@FreeBSD.ORG Mon May 26 13:45: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 1FB5C193 for ; Mon, 26 May 2014 13:45:10 +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 9975D24C7 for ; Mon, 26 May 2014 13:45:09 +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 s4QDj0DH090904; Mon, 26 May 2014 16:45:00 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.3 kib.kiev.ua s4QDj0DH090904 Received: (from kostik@localhost) by tom.home (8.14.8/8.14.8/Submit) id s4QDivHT090896; Mon, 26 May 2014 16:44:57 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 26 May 2014 16:44:57 +0300 From: Konstantin Belousov To: Peter Jeremy Subject: Re: i386 Go programs crash on amd64 Message-ID: <20140526134457.GR74331@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> <20140524074101.GI74331@kib.kiev.ua> <20140526113622.GB96083@server.rulingia.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lMELkkGiwR4F0HOc" Content-Disposition: inline In-Reply-To: <20140526113622.GB96083@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: Mon, 26 May 2014 13:45:10 -0000 --lMELkkGiwR4F0HOc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 some spills from (probably) Go runtime. I am not sure that this is something which should be looked at from the kernel side, at least initially. 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 ? What I see is: pooma% ./write-go ~/build/bsd/DEV/stuff/t= ests runtime: newstack called from g=3D0x382d5500 m=3D0x382e5800 m->curg=3D0x0 m->g0=3D0x382d55a0 m->gsignal=3D0x382d= 5500 fatal error: runtime: wrong goroutine in newstack runtime stack: runtime.throw(0x8096910) /usr/local/go/src/pkg/runtime/panic.c:464 +0x5f runtime.newstack() /usr/local/go/src/pkg/runtime/stack.c:212 +0x90 runtime.morestack() /usr/local/go/src/pkg/runtime/asm_386.s:246 +0x5e Hello World goroutine 1 [panicwait]: runtime.park(0x0, 0x0, 0x8097b74) /usr/local/go/src/pkg/runtime/proc.c:1342 +0x59 runtime.main() /usr/local/go/src/pkg/runtime/proc.c:229 +0x125 runtime.goexit() /usr/local/go/src/pkg/runtime/proc.c:1394 [1] 1537 segmentation fault (core dumped) ./write-go --lMELkkGiwR4F0HOc Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iQIcBAEBAgAGBQJTg0VZAAoJEJDCuSvBvK1BPE8P/1wPkRkMq9GaYx+J2BTVtx95 FS4lbpNvv6yDHyjqhdxmL1YQymrLEfHlG0mnIvxK6CDyYGQt9gd+/yTkqPNSWkN5 AdNAfIgg35/ITChEQmuGBTjZDkLfMrr4vD1NC7CSP87GTCMySntzm5cBTj1NOK9/ tezG8I12JTuVbIYlH4iJ7Fb8FvOJ8fcdVPq/75XhlIKIfGoKNaXcm2jR1QKkTov2 IBuTdvkudcJcrXsQ/V48EjTCrjfhQkh0etJG2ZQj4smMsFFOvGVE209wzETXudRW LvpctAHiFlLhQJ0QCsKodFMaMU+LRdU7omXGT22ulXCQ5nIdlKbt1lveabP+asH7 L5QJqqr0x4CJ9J6aP5Netg43EMSEiJ1fK1b9VrI/6WsoflZuywiS3B6wQvwJw1zF beiLo1psjlhGLYvJSY/9b4lU3ghdYMHiviZf0i2Yb505f43CRJgkSv6PZQXIJSrb TJC6/fa3HjKFnpjVLPdp3Xln1jY1GWhL9MBZTUpodn/F1Jyb6tpov3iNisYOhbXr GEALqcYP9mNZnl4z59HbQF370yJEddfPvLIMpogqFWK7qDtedPVe39s4Wa2m/OTK ANZ6ZmYMq4A+5LuMUXiMcvX3FQ4fHxCjHpc4QwNR313NLYI79iVQ3ZLmSjmvLtr4 fzt+H4Q9GDeTP3+mA1B1 =6PlJ -----END PGP SIGNATURE----- --lMELkkGiwR4F0HOc--