pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Peter <pmc@citylink.dinoex.sub.org>
Cc: pgsql-admin@postgresql.org
Cc: pgsql@FreeBSD.org
Subject: Re: Upgrade 10.5->10.6 : db crash BUS ERROR (sig 10), reproducible
Date: Fri, 08 Mar 2019 16:51:47 +0000
Message-ID: <87ef7hbal7.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <20190308152238.GA50588@gate.oper.dinoex.org>
References: <20190308012012.GA49481@gate.oper.dinoex.org>
	<87lg1qaxr2.fsf@news-spur.riddles.org.uk>
	<20190308152238.GA50588@gate.oper.dinoex.org>

>>>>> "Peter" == Peter  <pmc@citylink.dinoex.sub.org> 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 <pg_checksum_page+866>:      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)




view thread (20+ messages)  latest in thread

Message-ID: <87ef7hbal7.fsf@news-spur.riddles.org.uk>
Permalink:  ../87ef7hbal7.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87ef7hbal7.fsf@news-spur.riddles.org.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, pmc@citylink.dinoex.sub.org, pgsql@FreeBSD.org
  Subject: Re: Upgrade 10.5->10.6 : db crash BUS ERROR (sig 10), reproducible
  In-Reply-To: <87ef7hbal7.fsf@news-spur.riddles.org.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox