pgsql: llvmjit: Also copy parameter / return value attributes from temp

Lists: pgsql-committers
From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: llvmjit: Also copy parameter / return value attributes from temp
Date: 2020-10-15 22:22:33
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-committers

llvmjit: Also copy parameter / return value attributes from template functions.

Previously we only copied the function attributes. That caused problems at
least on s390x: Because we didn't copy the 'zeroext' attribute for
ExecAggTransReparent()'s *IsNull parameters, expressions invoking it didn't
ensure that the upper bytes of the registers were zeroed. In the - relatively
rare - cases where not, ExecAggTransReparent() wrongly ended up in the
newValueIsNull branch due to the register not being zero. Subsequently causing
a crash.

It's quite possible that this would cause problems on other platforms, and in
other places than just ExecAggTransReparent() on s390x.

Thanks to Christoph (and the Debian project) for providing me with access to a
s390x machine, allowing me to debug this.

Reported-By: Christoph Berg
Author: Andres Freund
Discussion: https://postgr.es/m/[email protected]
Backpatch: 11-, where JIT was added

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c8a2bb0f1abfa2c6ca4ed253a581431855e639c5

Modified Files
--------------
src/backend/jit/llvm/llvmjit.c | 44 ++++++++++++++++++++++++++++++------------
1 file changed, 32 insertions(+), 12 deletions(-)