Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Oct 2014 21:37:54 +0200
From:      Dimitry Andric <dim@FreeBSD.org>
To:        Larry Baird <lab@gta.com>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>, Ryan Stone <rysto32@gmail.com>
Subject:   Re: Kernel/Compiler bug
Message-ID:  <FBB9E4C3-55B9-4917-9953-F8BC9AE43619@FreeBSD.org>
In-Reply-To: <20141001134044.GA57022@gta.com>
References:  <20141001031553.GA14360@gta.com> <CAFMmRNxAYcr8eEY0SJsX3zkRadjT29-mfsGcSTmG_Yx-Hidi6w@mail.gmail.com> <20141001134044.GA57022@gta.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--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 <lab@gta.com> 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?FBB9E4C3-55B9-4917-9953-F8BC9AE43619>