Fix leak of LLVM "fatal-on-oom" section counter.
authorHeikki Linnakangas <[email protected]>
Wed, 5 Jul 2023 10:13:13 +0000 (13:13 +0300)
committerHeikki Linnakangas <[email protected]>
Wed, 5 Jul 2023 10:13:39 +0000 (13:13 +0300)
llvm_release_context() called llvm_enter_fatal_on_oom(), but was missing
the corresponding llvm_leave_fatal_on_oom() call. As a result, if JIT was
used at all, we were almost always in the "fatal-on-oom" state.

It only makes a difference if you use an extension written in C++, and
run out of memory in a C++ 'new' call. In that case, you would get a
PostgreSQL FATAL error, instead of the default behavior of throwing a
C++ exception.

Back-patch to all supported versions.

Reviewed-by: Daniel Gustafsson
Discussion: https://www.postgresql.org/message-id/54b78cca-bc84-dad8-4a7e-5b56f764fab5@iki.fi

src/backend/jit/llvm/llvmjit.c

index c8e67c6cbafc1414537d5bd0912be1c78545d348..4fd39d7853a359d6de0046ba7182ea5a2da595b6 100644 (file)
@@ -221,6 +221,8 @@ llvm_release_context(JitContext *context)
    }
    list_free(llvm_context->handles);
    llvm_context->handles = NIL;
+
+   llvm_leave_fatal_on_oom();
 }
 
 /*