pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #16456: Implicit unsigned integer truncation at multixact.c:2626
2+ messages / 2 participants
[nested] [flat]

* BUG #16456: Implicit unsigned integer truncation at multixact.c:2626
@ 2020-05-23 14:21 PG Bug reporting form <noreply@postgresql.org>
  2020-05-25 04:58 ` Re: BUG #16456: Implicit unsigned integer truncation at multixact.c:2626 Kyotaro Horiguchi <horikyota.ntt@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2020-05-23 14:21 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: tlock.chijin@gmail.com

The following bug has been logged on the website:

Bug reference:      16456
Logged by:          ChiJin Zhou
Email address:      tlock.chijin@gmail.com
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)));
        }
```



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #16456: Implicit unsigned integer truncation at multixact.c:2626
  2020-05-23 14:21 BUG #16456: Implicit unsigned integer truncation at multixact.c:2626 PG Bug reporting form <noreply@postgresql.org>
@ 2020-05-25 04:58 ` Kyotaro Horiguchi <horikyota.ntt@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Kyotaro Horiguchi @ 2020-05-25 04:58 UTC (permalink / raw)
  To: tlock.chijin@gmail.com; pgsql-bugs@lists.postgresql.org; noreply@postgresql.org

Hello.

At Sat, 23 May 2020 14:21:38 +0000, PG Bug reporting form <noreply@postgresql.org> wrote in 
> 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:

I'm not sure how the UndefinedBehaviorSanitizer works in details, but
the output of such kind of tools should need examiniations considering
the context of the code around.

> 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)                                                    
...
> 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.

The variable is used in a wrap-arounded way.  Although the
intermediate result tentatively becomes 64bits long because of size_t
contained in the expression, the result logically doesn't go beyond
32bit range and no bits of information are not lost through the down
conversion.

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2020-05-25 04:58 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-05-23 14:21 BUG #16456: Implicit unsigned integer truncation at multixact.c:2626 PG Bug reporting form <noreply@postgresql.org>
2020-05-25 04:58 ` Kyotaro Horiguchi <horikyota.ntt@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox