PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID16456
PG Version12.3
OSubuntu 18.04
Opened2020-05-23 14:21:38+00
Reported byChiJin Zhou
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      16456
Logged by:          ChiJin Zhou
Email address:      (redacted)
PostgreSQL version: 12.3
Operating system:   ubuntu 18.04
Description:        

ChiJin Zhou <tlock.chijin@gmail.com>
下午9:56 (24分钟前)
发送至 pgsql-bugs

REPRODUCTION && ERROR MESSAGE:

compile the postgres project with UndefinedBehaviorSanitizer and start a
start a server with "postgress" (command: "./postgres -Ddata -p23333"), and
Ubsan reported an error message:

multixact.c:2626:19: runtime error: implicit conversion from type 'unsigned
long' of value 18446744073709499264 (64-bit, unsigned) to type
'MultiXactOffset' (aka 'unsigned int') changed the value to 42949
14944 (32-bit, unsigned)                                                    
                         
    #0 0x7c037f in SetOffsetVacuumLimit
/root/chijin_workshop/postgres-new/postgres_source_enhanced/src/backend/access/transam/multixact.c:2626:19
                                                         
    #1 0x7c037f in SetMultiXactIdLimit
/root/chijin_workshop/postgres-new/postgres_source_enhanced/src/backend/access/transam/multixact.c:2286:24
                                                         
    #2 0x803673 in StartupXLOG
/root/chijin_workshop/postgres-new/postgres_source_enhanced/src/backend/access/transam/xlog.c:7715:2
                                                                       
    #3 0xf3c58a in StartupProcessMain
/root/chijin_workshop/postgres-new/postgres_source_enhanced/src/backend/postmaster/startup.c:207:2
                                                                   
    #4 0x82df1f in AuxiliaryProcessMain
/root/chijin_workshop/postgres-new/postgres_source_enhanced/src/backend/bootstrap/bootstrap.c:451:4
                                                               
    #5 0xf34d1c in StartChildProcess
/root/chijin_workshop/postgres-new/postgres_source_enhanced/src/backend/postmaster/postmaster.c:5428:3
                                                               
    #6 0xf32042 in PostmasterMain
/root/chijin_workshop/postgres-new/postgres_source_enhanced/src/backend/postmaster/postmaster.c:1389:15
                                                                 
    #7 0xc9bc14 in main
/root/chijin_workshop/postgres-new/postgres_source_enhanced/src/backend/main/main.c:212:3
                                     
    #8 0x7ffff7c82001 in __libc_start_main (/usr/lib/libc.so.6+0x27001)
    #9 0x57221d in _start
(/root/chijin_workshop/postgres-new/binaries_enhanced/postgres+0x57221d)

SUMMARY: UndefinedBehaviorSanitizer: implicit-unsigned-integer-truncation
multixact.c:2626:19 in
2020-05-23 21:10:44.894 CST [3417516] LOG:  startup process (PID 3417518)
was terminated by signal 6: Aborted

ROOT CAUSE CODE

The root cause code are shown bellow (multixact.c:2626). I believe that
*offsetStopLimit* is a uint32 and *MULTIXACT_MEMBERS_PER_PAGE *
SLRU_PAGES_PER_SEGMENT* cannot presented as uint32.
```c
        if (oldestOffsetKnown)
        {
                /* move back to start of the corresponding segment */
                offsetStopLimit = oldestOffset - (oldestOffset %
                                                                            
     (MULTIXACT_MEMBERS_PER_PAGE * SLRU_PAGES_PER_SEGMENT));

                /* always leave one segment before the wraparound point */
                offsetStopLimit -= (MULTIXACT_MEMBERS_PER_PAGE *
SLRU_PAGES_PER_SEGMENT);               <----------------------- root cause
code

                if (!prevOldestOffsetKnown && !is_startup)
                        ereport(LOG,
                                        (errmsg("MultiXact member wraparound
protections are now enabled")));

                ereport(DEBUG1,
                                (errmsg("MultiXact member stop limit is now
%u based on MultiXact %u",
                                                offsetStopLimit,
oldestMultiXactId)));
        }
```

Messages

DateAuthorSubject
2020-05-23 14:21:38+00PG Bug reporting formBUG #16456: Implicit unsigned integer truncation at multixact.c:2626
2020-05-25 04:58:28+00Kyotaro HoriguchiRe: BUG #16456: Implicit unsigned integer truncation at multixact.c:2626