Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h2Iiz-0008IX-FX for pgsql-admin@arkaria.postgresql.org; Fri, 08 Mar 2019 16:51:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h2Iiy-0003wz-5M for pgsql-admin@arkaria.postgresql.org; Fri, 08 Mar 2019 16:51:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h2Iix-0003rv-Pw for pgsql-admin@lists.postgresql.org; Fri, 08 Mar 2019 16:51:55 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h2Iiu-0007sU-Kq for pgsql-admin@postgresql.org; Fri, 08 Mar 2019 16:51:54 +0000 Received: from [192.168.127.1] (port=20745 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1h2Iir-0002mr-Eq; Fri, 08 Mar 2019 16:51:49 +0000 Received: from [127.0.0.1] (port=36697 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1h2Iiq-000GWA-Ly; Fri, 08 Mar 2019 16:51:48 +0000 From: Andrew Gierth To: Peter Cc: pgsql-admin@postgresql.org, pgsql@FreeBSD.org Subject: Re: Upgrade 10.5->10.6 : db crash BUS ERROR (sig 10), reproducible In-Reply-To: <20190308152238.GA50588@gate.oper.dinoex.org> (Peter's message of "Fri, 8 Mar 2019 16:22:38 +0100") Message-ID: <87ef7hbal7.fsf@news-spur.riddles.org.uk> References: <20190308012012.GA49481@gate.oper.dinoex.org> <87lg1qaxr2.fsf@news-spur.riddles.org.uk> <20190308152238.GA50588@gate.oper.dinoex.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Fri, 08 Mar 2019 16:51:47 +0000 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Peter" == Peter writes: Peter> esp 0x7fbfc15c 0x7fbfc15c And there we go; the stack is misaligned. (only 4 byte alignment where 16 is expected). Peter> eip 0x838bdf2 0x838bdf2 Peter> 0x0838bdf2 : movaps 0x20(%esp),%xmm0 MOVAPS is an SSE (not SSE2) instruction; it's enabled by virtue of the fact that you used -march=pentium3 (the pentium3 supports SSE but not SSE2). The "A" stands for "aligned"; an unaligned source address causes an exception. %esp+0x20 is not correctly aligned for the instruction. GCC defaults to using a 16-byte stack alignment, but it relies on the caller to align the stack too, so if a GCC-compiled function is called from code that doesn't align the stack, then this kind of error can result. I do not know offhand (but I plan to find out) what clang's default stack alignment on i386 is. You can tell GCC to realign the stack itself using the -mstackrealign option. This problem shows up only with GCC and not with clang because clang does not attempt to use SSE to vectorize this particular piece of code. The non-vectorized implementation generated by clang has no special requirements for stack alignment. But at the end of the day this is not a problem with PostgreSQL - it would show up with any code compiled with GCC where the compiler had elected to use SSE instructions for optimization. -- Andrew (irc:RhodiumToad)