aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2021-06-25 09:55:26 +1200
committerThomas Munro <tmunro@postgresql.org>2021-06-25 11:29:20 +1200
commit47d22649e6a233a44030ef357969ade85f3ba724 (patch)
treef59a510fcbe632c27b0b87cfe3feef2deecbe23c
parent79ff96aa9d9a76cf6fd5ade9a25efb488ecd89ab (diff)
downloadpostgresql-47d22649e6a233a44030ef357969ade85f3ba724.tar.gz
postgresql-47d22649e6a233a44030ef357969ade85f3ba724.zip
Prepare for forthcoming LLVM 13 API change.
LLVM 13 (due out in September) has changed the semantics of LLVMOrcAbsoluteSymbols(), so we need to bump some reference counts to avoid a double-free that causes crashes and bad query results. A proactive change seems necessary to avoid having a window of time where our respective latest releases would interact badly. It's possible that the situation could change before then, though. Thanks to Fabien Coelho for monitoring bleeding edge LLVM and Andres Freund for tracking down the change. Back-patch to 11, where the JIT code arrived. Discussion: https://postgr.es/m/CA%2BhUKGLEy8mgtN7BNp0ooFAjUedDTJj5dME7NxLU-m91b85siA%40mail.gmail.com
-rw-r--r--src/backend/jit/llvm/llvmjit.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/jit/llvm/llvmjit.c b/src/backend/jit/llvm/llvmjit.c
index 3b8bc291fcc..638574f4809 100644
--- a/src/backend/jit/llvm/llvmjit.c
+++ b/src/backend/jit/llvm/llvmjit.c
@@ -1108,6 +1108,9 @@ llvm_resolve_symbols(LLVMOrcDefinitionGeneratorRef GeneratorObj, void *Ctx,
{
const char *name = LLVMOrcSymbolStringPoolEntryStr(LookupSet[i].Name);
+#if LLVM_VERSION_MAJOR > 12
+ LLVMOrcRetainSymbolStringPoolEntry(LookupSet[i].Name);
+#endif
symbols[i].Name = LookupSet[i].Name;
symbols[i].Sym.Address = llvm_resolve_symbol(name, NULL);
symbols[i].Sym.Flags.GenericFlags = LLVMJITSymbolGenericFlagsExported;