From owner-freebsd-hackers@FreeBSD.ORG Wed Oct 1 19:38:17 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1AF2EC68 for ; Wed, 1 Oct 2014 19:38:17 +0000 (UTC) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "tensor.andric.com", Issuer "CAcert Class 3 Root" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id CAB8EBB0 for ; Wed, 1 Oct 2014 19:38:16 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7::e57d:9fd2:d3a8:dc94] (unknown [IPv6:2001:7b8:3a7:0:e57d:9fd2:d3a8:dc94]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 1255EB80A; Wed, 1 Oct 2014 21:38:07 +0200 (CEST) Content-Type: multipart/signed; boundary="Apple-Mail=_FE3828C5-4D92-4392-AE93-72655D74AB90"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: Kernel/Compiler bug From: Dimitry Andric In-Reply-To: <20141001134044.GA57022@gta.com> Date: Wed, 1 Oct 2014 21:37:54 +0200 Message-Id: References: <20141001031553.GA14360@gta.com> <20141001134044.GA57022@gta.com> To: Larry Baird X-Mailer: Apple Mail (2.1878.6) Cc: "freebsd-hackers@freebsd.org" , Ryan Stone X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Oct 2014 19:38:17 -0000 --Apple-Mail=_FE3828C5-4D92-4392-AE93-72655D74AB90 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii On 01 Oct 2014, at 15:40, Larry Baird wrote: > Ryan, > > On Wed, Oct 01, 2014 at 12:46:35AM -0400, Ryan Stone wrote: >> This may not be a compiler bug. A quick look at the esp values >> provided in that backtrace shows that at least 7KB has been used on >> the stack. The stack for kernel threads is only 8KB, and a stack >> overflow can cause a double fault like that. >> >> My suspicion would be that without optimizations on clang uses a lot >> more stack space and you push over the limit. There's a kernel build >> option for the stack size that you could change to confirm. I believe >> that it's called KSTACK_PAGES. Try increasing it to 4. > Good catch. Increasing KSTACK_PAGES does fix the issue. I wonder with > optimization, how close to stack overflow does the kernel get during boot? It obviously depends on which optimization flags you use, which drivers you include, and so on. There was a thread some time ago about somebody banging into the limit when mounting certain ZFS filesystems, here: https://lists.freebsd.org/pipermail/freebsd-current/2012-December/038208.html This is why Kostik added printing of the frame addresses to the panic backtrace output, so you can easily see if you hit the stack limit. That said, 8k is not much these days, especially not with fairly complicated code like ZFS, combined with high optimization, which can inline a lot of functions, causing even more stack usage. I would just bump KSTACK_PAGES. -Dimitry --Apple-Mail=_FE3828C5-4D92-4392-AE93-72655D74AB90 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iEYEARECAAYFAlQsWBoACgkQsF6jCi4glqN8zgCeNe0ZiuINVUj9/pZCd3fUiu0R 2uEAoJc3rkdOrAgsYfXSuqrzltEVscAQ =uHtI -----END PGP SIGNATURE----- --Apple-Mail=_FE3828C5-4D92-4392-AE93-72655D74AB90--