BUG #16456: Implicit unsigned integer truncation at multixact.c:2626

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: tlock(dot)chijin(at)gmail(dot)com
Subject: BUG #16456: Implicit unsigned integer truncation at multixact.c:2626
Date: 2020-05-23 14:21:38
Message-ID: 16456-1f064151928ad861@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16456
Logged by: ChiJin Zhou
Email address: tlock(dot)chijin(at)gmail(dot)com
PostgreSQL version: 12.3
Operating system: ubuntu 18.04
Description:

ChiJin Zhou <tlock(dot)chijin(at)gmail(dot)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)));
}
```

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2020-05-24 15:43:03 BUG #16457: Implicit signed integer truncation or sign change at sortsupport.c:60
Previous Message Alexey Bashtanov 2020-05-22 21:08:22 Re: planner weirdness: a join uses nestloop with checking condition when there are two subplan-or-hashed subqueries