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

yjhjstz 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 4b9657f357c Fix type mismatch in dsm_attach() argument by using 
DatumGetUInt32()
4b9657f357c is described below

commit 4b9657f357c24a18023e47c23a2be029e4139106
Author: Jianghua Yang <[email protected]>
AuthorDate: Fri Jun 27 03:30:35 2025 +0800

    Fix type mismatch in dsm_attach() argument by using DatumGetUInt32()
    
    The argument passed to dsm_attach() represents a dynamic shared memory
    segment handle, which is defined as a uint32. The existing code incorrectly
    used DatumGetInt32(), which may lead to unexpected behavior if the value
    exceeds the range of a signed 32-bit integer.
---
 src/backend/task/pg_cron.c            | 2 +-
 src/test/modules/test_shm_mq/worker.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/task/pg_cron.c b/src/backend/task/pg_cron.c
index ac5cfbe82bc..0c1fdb9156d 100644
--- a/src/backend/task/pg_cron.c
+++ b/src/backend/task/pg_cron.c
@@ -1784,7 +1784,7 @@ CronBackgroundWorker(Datum main_arg)
                                                                                
                 ALLOCSET_DEFAULT_MAXSIZE);
 
        /* Set up a dynamic shared memory segment. */
-       seg = dsm_attach(DatumGetInt32(main_arg));
+       seg = dsm_attach(DatumGetUInt32(main_arg));
        if (seg == NULL)
                ereport(ERROR,
                                
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
diff --git a/src/test/modules/test_shm_mq/worker.c 
b/src/test/modules/test_shm_mq/worker.c
index 2180776a669..5b30454dd22 100644
--- a/src/test/modules/test_shm_mq/worker.c
+++ b/src/test/modules/test_shm_mq/worker.c
@@ -77,7 +77,7 @@ test_shm_mq_main(Datum main_arg)
         * exit, which is fine.  If there were a ResourceOwner, it would acquire
         * ownership of the mapping, but we have no need for that.
         */
-       seg = dsm_attach(DatumGetInt32(main_arg));
+       seg = dsm_attach(DatumGetUInt32(main_arg));
        if (seg == NULL)
                ereport(ERROR,
                                
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),


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

Reply via email to