Re: JIT compiling with LLVM v11

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Pierre Ducroquet <p(dot)psql(at)pinaraf(dot)info>
Subject: Re: JIT compiling with LLVM v11
Date: 2018-03-07 02:49:31
Message-ID: CAEepm=2Md2aP2Ey5wRsFufKhqkGiu-F7eQVCFQ3jMFheQKvVaA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 6, 2018 at 10:39 PM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> [more commits]

+ * OSX prefixes all object level symbols with an underscore. But neither

"macOS" (see commit da6c4f6c and all mentions since).

make check at today's HEAD of your jit branch crashes on my FreeBSD
box. The first thing to crash is this query from point.sql:

LOG: server process (PID 87060) was terminated by signal 4: Illegal instruction
DETAIL: Failed process was running: SELECT '' AS thirtysix, p1.f1 AS
point1, p2.f1 AS point2, p1.f1 <-> p2.f1 AS dist
FROM POINT_TBL p1, POINT_TBL p2
ORDER BY dist, p1.f1[0], p2.f1[0];

Unfortunately when I tried to load the core file into lldb, the stack
is like this:

* thread #1, name = 'postgres', stop reason = signal SIGILL
* frame #0: 0x0000000800e7c1ea

Apparently the generated code is nuking the stack and executing
garbage? I don't have time to investigate right now, and this may
indicate something busted in my environment, but I thought this might
tell you something.

These variants of that query don't crash (even though I set
jit_above_cost = 0 and checked that it's actually JIT-ing), which
might be clues:

-- no p1.f1 <-> p2.f1
SELECT p1.f1 AS point1, p2.f1 AS point2
FROM POINT_TBL p1, POINT_TBL p2
ORDER BY p1.f1[0], p2.f1[0];

-- no join
SELECT p1.f1 <-> p1.f1 AS dist
FROM POINT_TBL p1
ORDER BY 1;

These variants do crash:

-- p1.f1 <-> p2.f1 in order by, but not select list
SELECT p1.f1 AS point1, p2.f1 AS point2
FROM POINT_TBL p1, POINT_TBL p2
ORDER BY p1.f1 <-> p2.f1, p1.f1[0], p2.f1[0];

-- p1.f1 <-> p2.f1 in select list, but not in order by
SELECT p1.f1 AS point1, p2.f1 AS point2, p1.f1 <-> p2.f1 AS dist
FROM POINT_TBL p1, POINT_TBL p2
ORDER BY p1.f1[0], p2.f1[0];

-- simple, with a join
SELECT p1.f1 <-> p1.f1 AS dist
FROM POINT_TBL p1, POINT_TBL p2
ORDER BY 1;

I build it like this:

./configure \
--prefix=$HOME/install/ \
--enable-tap-tests \
--enable-cassert \
--enable-debug \
--enable-depend \
--with-llvm \
CC="ccache cc" CFLAGS="-O0" CXX="ccache c++" CXXFLAGS="-std=c++11" \
CLANG=/usr/local/llvm50/bin/clang \
LLVM_CONFIG=/usr/local/llvm50/bin/llvm-config \
--with-libraries="/usr/local/lib" \
--with-includes="/usr/local/include"

--
Thomas Munro
http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2018-03-07 02:56:38 Re: Suspicious call of initial_cost_hashjoin()
Previous Message Peter Eisentraut 2018-03-07 02:49:07 Re: [doc fix] Correct calculation of vm.nr_hugepages