]> git.ipfire.org Git - thirdparty/postgresql.git/commit
jit: Do not try to shut down LLVM state in case of LLVM triggered errors.
authorAndres Freund <andres@anarazel.de>
Tue, 14 Sep 2021 01:07:19 +0000 (18:07 -0700)
committerAndres Freund <andres@anarazel.de>
Tue, 14 Sep 2021 01:26:18 +0000 (18:26 -0700)
commitdccffd9a274dfbf343008c4da8029ed8b1f35ea2
tree83cc0100d3b888de2357482e0cfa9afc4cce7353
parentbdd6ce48d0356fbfaa0fe4a1fee20068f99abb70
jit: Do not try to shut down LLVM state in case of LLVM triggered errors.

If an allocation failed within LLVM it is not safe to call back into LLVM as
LLVM is not generally safe against exceptions / stack-unwinding. Thus errors
while in LLVM code are promoted to FATAL. However llvm_shutdown() did call
back into LLVM even in such cases, while llvm_release_context() was careful
not to do so.

We cannot generally skip shutting down LLVM, as that can break profiling. But
it's OK to do so if there was an error from within LLVM.

Reported-By: Jelte Fennema <Jelte.Fennema@microsoft.com>
Author: Andres Freund <andres@anarazel.de>
Author: Justin Pryzby <pryzby@telsasoft.com>
Discussion: https://postgr.es/m/AM5PR83MB0178C52CCA0A8DEA0207DC14F7FF9@AM5PR83MB0178.EURPRD83.prod.outlook.com
Backpatch: 11-, where jit was introduced
src/backend/jit/llvm/llvmjit.c
src/backend/jit/llvm/llvmjit_error.cpp
src/include/jit/llvmjit.h