Bug 13431

Summary: pmap output wrongly formated on 32bit system
Product: Busybox Reporter: Ronald Wahl <ronald.wahl>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: 1.32.x   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Host: Target:
Build:

Description Ronald Wahl 2021-01-05 17:08:28 UTC
Commit aad76968cd5 (pmap: make 32-bit version work better on 64-bit kernels) broke formatting on 32bit system:

--8<--
# pmap -x $$
1121: -sh
Address   Kbytes     PSS   Dirty    Swap  Mode  Mapping
0000000008048000     336     105       0       0  r-xp  /bin/busybox
000000000809c000       4       4       4       0  r--p  /bin/busybox
000000000809d000       4       4       4       0  rw-p  /bin/busybox
0000000009933000      12      12      12       0  rw-p  [heap]
00000000b7f00000     504      12       0       0  r-xp  /lib/libuClibc-1.0.36.so
00000000b7f7e000       4       4       4       0  r--p  /lib/libuClibc-1.0.36.so
00000000b7f7f000       4       4       4       0  rw-p  /lib/libuClibc-1.0.36.so
00000000b7f80000      96      20      20       0  rw-p    [ anon ]
00000000b7f98000      12       0       0       0  r--p  [vvar]
00000000b7f9b000       4       0       0       0  r-xp  [vdso]
00000000b7f9c000      28       0       0       0  r-xp  /lib/ld-uClibc-1.0.36.so
00000000b7fa3000       4       4       4       0  r--p  /lib/ld-uClibc-1.0.36.so
00000000b7fa4000       4       4       4       0  rw-p  /lib/ld-uClibc-1.0.36.so
00000000bf8b9000     132      12      12       0  rw-p  [stack]
--------  ------  ------  ------  ------
total       1148     185      68       0

--8<--

From procps/pmap.c:

#if ULONG_MAX == 0xffffffff
# define TABS "\t"
# define AFMT "8"
# define DASHES ""
#else
# define TABS "\t\t"
# define AFMT "16"
# define DASHES "--------"
#endif

AFMT is not used anymore.

The following condition is bogus - ULLONG_MAX will never be 0xffffffff because long long is (at least) a 64bit value.

TABS/DASHES should be consistent to the AFMTLL value below.

#if ULLONG_MAX == 0xffffffff
# define AFMTLL "8"
#else
# define AFMTLL "16"
#endif


Maybe replace all of this by

#define AFMTLL "16"
#define TABS "\t\t"
#define DASHES "--------"
Comment 1 Denys Vlasenko 2021-01-05 18:40:11 UTC
Fixed in git.