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-08 11:33:03
Message-ID: CAEepm=1oLBeRjGw9RS6n=u0fE4t0WZMMawcfJopkmTmxRoefGw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Mar 7, 2018 at 3:49 PM, Thomas Munro
<thomas(dot)munro(at)enterprisedb(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message amul sul 2018-03-08 12:08:24 Re: [HACKERS] Restrict concurrent update/delete with UPDATE of partition key
Previous Message Amit Khandekar 2018-03-08 11:25:14 Concurrency bug in UPDATE of partition-key