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

From Thomas Munro
Subject Re: JIT compiling with LLVM v11
Date
Msg-id CAEepm=1oLBeRjGw9RS6n=u0fE4t0WZMMawcfJopkmTmxRoefGw@mail.gmail.com
Whole thread Raw
In response to Re: JIT compiling with LLVM v11  (Thomas Munro <thomas.munro@enterprisedb.com>)
Responses Re: JIT compiling with LLVM v11  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On Wed, Mar 7, 2018 at 3:49 PM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> 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];

Hmm.  It's trying to execute an AVX instruction.

* thread #1, stop reason = breakpoint 1.1
    frame #0: llvmjit.so`ExecRunCompiledExpr(state=0x0000000801de4880,
econtext=0x0000000801de3560, isNull="") at llvmjit_expr.c:432
   429
   430          state->evalfunc = func;
   431
-> 432          return func(state, econtext, isNull);
   433  }
   434
   435  static void emit_lifetime_end(ExprState *state, LLVMModuleRef
mod, LLVMBuilderRef b);
(lldb) s
Process 44513 stopped
* thread #1, stop reason = signal SIGILL: privileged instruction
    frame #0: 0x0000000801157193
->  0x801157193: vmovsd (%rax), %xmm0             ; xmm0 = mem[0],zero
    0x801157197: vmovsd 0x8(%rax), %xmm1          ; xmm1 = mem[0],zero
    0x80115719c: vsubsd (%rcx), %xmm0, %xmm2
    0x8011571a0: vsubsd 0x8(%rcx), %xmm1, %xmm0
(lldb) bt
* thread #1, stop reason = signal SIGILL: privileged instruction
  * frame #0: 0x0000000801157193

This is running on a "Intel(R) Celeron(R) CPU G1610T @ 2.30GHz" with no AVX.

I am not sure if that is real though, because the stack is immediately
corrupted.  So either func is not really a function, or it is but was
compiled for the wrong target.  I see that you call
LLVMCreateTargetMachine() with the result of LLVMGetHostCPUName() as
cpu.  For me that's "ivybridge", so I tried hard coding "generic"
instead and it didn't help.  I see that you say "" for features, where
is where one would normally put "avx" to turn on AVX instructions, so
I think perhaps that theory is entirely bogus.

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


pgsql-hackers by date:

Previous
From: Amit Khandekar
Date:
Subject: Concurrency bug in UPDATE of partition-key
Next
From: amul sul
Date:
Subject: Re: [HACKERS] Restrict concurrent update/delete with UPDATE ofpartition key