This is an automated email from the ASF dual-hosted git repository.

maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git


The following commit(s) were added to refs/heads/main by this push:
     new 3fbebeae14 fix coredump in interconnect_abort_callback
3fbebeae14 is described below

commit 3fbebeae14e6cbe252e120cdc23552140deeba94
Author: GongXun <[email protected]>
AuthorDate: Mon May 26 19:29:05 2025 +0800

    fix coredump in interconnect_abort_callback
    
    In the exception handling logic of interconnect_abort_callback, we invoked
    elog(ERROR) without properly handling the PostgreSQL exception using
    PG_TRY/PG_CATCH. This oversight could lead to the process exiting 
abnormally.
    
    When an uncaught PostgreSQL exception occurs in the exception handling
    function registered via RegisterResourceReleaseCallback, the exception
    callback function is recursively invoked. This recursion may eventually
    cause the errordata stack to exceed its allocated size, triggering an
    ERROR(PANIC) and causing the process to terminate abnormally.
---
 contrib/interconnect/tcp/ic_tcp.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/contrib/interconnect/tcp/ic_tcp.c 
b/contrib/interconnect/tcp/ic_tcp.c
index 39ad2f9c4e..a3855c8777 100644
--- a/contrib/interconnect/tcp/ic_tcp.c
+++ b/contrib/interconnect/tcp/ic_tcp.c
@@ -1895,6 +1895,22 @@ SetupTCPInterconnect(EState *estate)
        estate->es_interconnect_is_setup = true;
 }                                                              /* 
SetupTCPInterconnect */
 
+static void TeardownInterconnectTCPCallbck(ChunkTransportState 
*transportStates,
+                                                                               
   bool hasErrors)
+{
+       PG_TRY();
+       {
+               TeardownTCPInterconnect(transportStates, hasErrors);
+       }
+       PG_CATCH();
+       {
+               char *error_message = elog_message();
+               elog(WARNING, "TeardownInterconnectTCPCallbck: failed to 
teardown interconnect, error: %s",
+                        error_message ? error_message : "unknown error");
+       }
+       PG_END_TRY();
+}
+
 void
 SetupInterconnectTCP(EState *estate)
 {
@@ -1910,7 +1926,7 @@ SetupInterconnectTCP(EState *estate)
                elog(ERROR, "SetupInterconnectTCP: no slice table ?");
        }
 
-       h = allocate_interconnect_handle(TeardownInterconnectTCP);
+       h = allocate_interconnect_handle(TeardownInterconnectTCPCallbck);
 
        Assert(InterconnectContext != NULL);
        oldContext = MemoryContextSwitchTo(InterconnectContext);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to