Re: JIT compiling with LLVM v11 - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: JIT compiling with LLVM v11
Date
Msg-id CAEepm=2Md2aP2Ey5wRsFufKhqkGiu-F7eQVCFQ3jMFheQKvVaA@mail.gmail.com
Whole thread Raw
In response to Re: JIT compiling with LLVM v11  (Andres Freund <andres@anarazel.de>)
Responses Re: JIT compiling with LLVM v11  (Thomas Munro <thomas.munro@enterprisedb.com>)
List pgsql-hackers
On Tue, Mar 6, 2018 at 10:39 PM, Andres Freund <andres@anarazel.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


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: [doc fix] Correct calculation of vm.nr_hugepages
Next
From: Peter Eisentraut
Date:
Subject: Re: Suspicious call of initial_cost_hashjoin()