https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114586

            Bug ID: 114586
           Summary: Contradictory paths in reasoning for memory leak
                    diagnostic
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: BenBE at geshi dot org
  Target Milestone: ---

Created attachment 57877
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57877&action=edit
Preprocessed Sources for linux/LinuxProcessTable.c

* Bug description:

When reasoning about the possible memory leak (I'm quite sure there is none),
the output in 53 and 57 should always take the same paths as the FILE*
allocated in 52 is passed directly in the assignment/function return from 55 to
56.

* Exact GCC version (gcc-14 -v):

```
$ gcc-14 -v
Using built-in specs.
COLLECT_GCC=gcc-14
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/14/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
14-20240330-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-14/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust --prefix=/usr
--with-gcc-major-version-only --program-suffix=-14
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-vtable-verify
--enable-plugin --enable-default-pie --with-system-zlib
--enable-libphobos-checking=release --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-14-qLjdS8/gcc-14-14-20240330/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-14-qLjdS8/gcc-14-14-20240330/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver
--enable-checking=yes,extra,rtl --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.1 20240330 (experimental) [master r14-9728-g6fc84f680d0]
(Ubuntu 14-20240330-1ubuntu2) 
```

* System Type:

```
$ uname -a
Linux hostname 6.8.0-20-generic #20-Ubuntu SMP PREEMPT_DYNAMIC Mon Mar 18
11:23:20 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu Noble Numbat (development branch)
Release:        24.04
Codename:       noble
```

* Build config of GCC: see above

* Complete command line to reproduce:

```
$ LC_ALL=C.UTF-8 LANG=C.UTF-8 depbase=`echo linux/LinuxProcessTable.o | sed
's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc-14 -v -save-temps -DHAVE_CONFIG_H -I.  -DNDEBUG  -std=c99 -pedantic
-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -I/usr/include/libnl3 
-I/usr/include/libnl3  -Wall -Wcast-align -Wcast-qual -Wextra -Wfloat-equal
-Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn
-Wmissing-prototypes -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef
-Wunused -Wwrite-strings -Wnull-dereference -D_XOPEN_SOURCE_EXTENDED
-DSYSCONFDIR="\"/usr/local/etc\"" -I"./linux" -fanalyzer
-Wanalyzer-infinite-loop -MT linux/LinuxProcessTable.o -MD -MP -MF $depbase.Tpo
-c -o linux/LinuxProcessTable.o linux/LinuxProcessTable.c &&\
mv -f $depbase.Tpo $depbase.Po
```

* Complete Compiler output:

```
Using built-in specs.
COLLECT_GCC=gcc-14
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
14-20240330-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-14/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust --prefix=/usr
--with-gcc-major-version-only --program-suffix=-14
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-vtable-verify
--enable-plugin --enable-default-pie --with-system-zlib
--enable-libphobos-checking=release --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-14-qLjdS8/gcc-14-14-20240330/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-14-qLjdS8/gcc-14-14-20240330/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver
--enable-checking=yes,extra,rtl --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.1 20240330 (experimental) [master r14-9728-g6fc84f680d0]
(Ubuntu 14-20240330-1ubuntu2) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-D' 'HAVE_CONFIG_H' '-I' '.' '-D'
'NDEBUG' '-std=c99' '-Wpedantic' '-D' '_DEFAULT_SOURCE' '-D'
'_XOPEN_SOURCE=600' '-I' '/usr/include/libnl3' '-I' '/usr/include/libnl3'
'-Wall' '-Wcast-align' '-Wcast-qual' '-Wextra' '-Wfloat-equal' '-Wformat=2'
'-Winit-self' '-Wsuggest-attribute=format' '-Wsuggest-attribute=noreturn'
'-Wmissing-prototypes' '-Wpointer-arith' '-Wshadow' '-Wstrict-prototypes'
'-Wundef' '-Wunused' '-Wwrite-strings' '-Wnull-dereference' '-D'
'_XOPEN_SOURCE_EXTENDED' '-D' 'SYSCONFDIR="/usr/local/etc"' '-I' './linux'
'-fanalyzer' '-Wanalyzer-infinite-loop' '-MT' 'linux/LinuxProcessTable.o' '-MD'
'-MP' '-MF' 'linux/.deps/LinuxProcessTable.Tpo' '-c' '-o'
'linux/LinuxProcessTable.o' '-mtune=generic' '-march=x86-64' '-dumpdir'
'linux/'
 /usr/libexec/gcc/x86_64-linux-gnu/14/cc1 -E -quiet -v -I . -I
/usr/include/libnl3 -I /usr/include/libnl3 -I ./linux -imultiarch
x86_64-linux-gnu -MD linux/LinuxProcessTable.d -MF
linux/.deps/LinuxProcessTable.Tpo -MP -MT linux/LinuxProcessTable.o -D
HAVE_CONFIG_H -D NDEBUG -D _DEFAULT_SOURCE -D _XOPEN_SOURCE=600 -D
_XOPEN_SOURCE_EXTENDED -D SYSCONFDIR="/usr/local/etc" linux/LinuxProcessTable.c
-mtune=generic -march=x86-64 -std=c99 -Wpedantic -Wall -Wcast-align -Wcast-qual
-Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wsuggest-attribute=format
-Wsuggest-attribute=noreturn -Wmissing-prototypes -Wpointer-arith -Wshadow
-Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -Wnull-dereference
-Wanalyzer-infinite-loop -fanalyzer -fpch-preprocess
-fasynchronous-unwind-tables -fstack-protector-strong -fstack-clash-protection
-fcf-protection -o linux/LinuxProcessTable.i
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/14/include-fixed/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/14/include-fixed"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include"
ignoring duplicate directory "/usr/include/libnl3"
#include "..." search starts here:
#include <...> search starts here:
 .
 /usr/include/libnl3
 ./linux
 /usr/lib/gcc/x86_64-linux-gnu/14/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-D' 'HAVE_CONFIG_H' '-I' '.' '-D'
'NDEBUG' '-std=c99' '-Wpedantic' '-D' '_DEFAULT_SOURCE' '-D'
'_XOPEN_SOURCE=600' '-I' '/usr/include/libnl3' '-I' '/usr/include/libnl3'
'-Wall' '-Wcast-align' '-Wcast-qual' '-Wextra' '-Wfloat-equal' '-Wformat=2'
'-Winit-self' '-Wsuggest-attribute=format' '-Wsuggest-attribute=noreturn'
'-Wmissing-prototypes' '-Wpointer-arith' '-Wshadow' '-Wstrict-prototypes'
'-Wundef' '-Wunused' '-Wwrite-strings' '-Wnull-dereference' '-D'
'_XOPEN_SOURCE_EXTENDED' '-D' 'SYSCONFDIR="/usr/local/etc"' '-I' './linux'
'-fanalyzer' '-Wanalyzer-infinite-loop' '-MT' 'linux/LinuxProcessTable.o' '-MD'
'-MP' '-MF' 'linux/.deps/LinuxProcessTable.Tpo' '-c' '-o'
'linux/LinuxProcessTable.o' '-mtune=generic' '-march=x86-64' '-dumpdir'
'linux/'
 /usr/libexec/gcc/x86_64-linux-gnu/14/cc1 -fpreprocessed
linux/LinuxProcessTable.i -quiet -dumpdir linux/ -dumpbase LinuxProcessTable.c
-dumpbase-ext .c -mtune=generic -march=x86-64 -Wpedantic -Wall -Wcast-align
-Wcast-qual -Wextra -Wfloat-equal -Wformat=2 -Winit-self
-Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wmissing-prototypes
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings
-Wnull-dereference -Wanalyzer-infinite-loop -std=c99 -version -fanalyzer
-fasynchronous-unwind-tables -fstack-protector-strong -fstack-clash-protection
-fcf-protection -o linux/LinuxProcessTable.s
GNU C99 (Ubuntu 14-20240330-1ubuntu2) version 14.0.1 20240330 (experimental)
[master r14-9728-g6fc84f680d0] (x86_64-linux-gnu)
        compiled by GNU C version 14.0.1 20240330 (experimental) [master
r14-9728-g6fc84f680d0], GMP version 6.3.0, MPFR version 4.2.1, MPC version
1.3.1, isl version isl-0.26-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: a9511c5586fa9828e58f62b3eff2e269
linux/LinuxProcessTable.c: In function ‘LinuxProcessTable_readMaps’:
linux/LinuxProcessTable.c:581:7: warning: leak of ‘mapsfile’ [CWE-401]
[-Wanalyzer-malloc-leak]
  581 |       return;
      |       ^~~~~~
  ‘ProcessTable_goThroughEntries’: event 1
    |
    |linux/LinuxProcessTable.c:1685:6:
    | 1685 | void ProcessTable_goThroughEntries(ProcessTable* super) {
    |      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |      |
    |      |      (1) entry to ‘ProcessTable_goThroughEntries’
    |
  ‘ProcessTable_goThroughEntries’: event 2
    |
    |linux/LinuxProcessTable.c:1720:4:
    | 1720 |    LinuxProcessTable_recurseProcTree(this, rootFd, lhost, PROCDIR,
NULL);
    |
    +--> ‘LinuxProcessTable_recurseProcTree’: event 3
           |
           |linux/LinuxProcessTable.c:1375:12:
           | 1375 | static bool
LinuxProcessTable_recurseProcTree(LinuxProcessTable* this, openat_arg_t
parentFd, const LinuxMachine* lhost, const char* dirname, const Process*
parent) {
           |      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |            |
           |      |            (3) entry to ‘LinuxProcessTable_recurseProcTree’
           |
         ‘LinuxProcessTable_recurseProcTree’: event 4
           |
           |linux/LinuxProcessTable.c:1387:7:
           | 1387 |    if (dirFd < 0)
           |      |       ^
           |      |       |
           |      |       (4) following ‘false’ branch (when ‘dirFd >= 0’)...
           |
         ‘LinuxProcessTable_recurseProcTree’: events 5-6
           |
           |linux/LinuxProcessTable.c:1389:15:
           | 1389 |    DIR* dir = fdopendir(dirFd);
           |      |               ^~~~~~~~~~~~~~~~
           |      |               |
           |      |               (5) ...to here
           |......
           | 1395 |    if (!dir) {
           |      |       ~        
           |      |       |
           |      |       (6) following ‘false’ branch (when ‘dir’ is
non-NULL)...
           |
         ‘LinuxProcessTable_recurseProcTree’: event 7
           |
           |linux/LinuxProcessTable.c:1400:14:
           | 1400 |    const bool hideKernelThreads =
settings->hideKernelThreads;
           |      |              ^~~~~~~~~~~~~~~~~
           |      |              |
           |      |              (7) ...to here
           |
         ‘LinuxProcessTable_recurseProcTree’: event 8
           |
           |linux/LinuxProcessTable.c:1403:34:
           | 1403 |    while ((entry = readdir(dir)) != NULL) {
           |
         ‘LinuxProcessTable_recurseProcTree’: event 9
           |
           |linux/LinuxProcessTable.c:1404:19:
           | 1404 |       const char* name = entry->d_name;
           |      |                   ^~~~
           |      |                   |
           |      |                   (9) ...to here
           |
         ‘LinuxProcessTable_recurseProcTree’: events 10-12
           |
           |linux/LinuxProcessTable.c:1418:10:
           | 1418 |       if (name[0] < '0' || name[0] > '9') {
           |      |          ^
           |      |          |
           |      |          (10) following ‘false’ branch...
           |......
           | 1426 |          unsigned long parsedPid = strtoul(name, &endptr,
10);
           |      |                                   
~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |                                    |
           |      |                                    (11) ...to here
           | 1427 |          if (parsedPid == 0 || parsedPid == ULONG_MAX ||
*endptr != '\0')
           |      |             ~
           |      |             |
           |      |             (12) following ‘false’ branch...
           |
         ‘LinuxProcessTable_recurseProcTree’: events 13-15
           |
           |linux/LinuxProcessTable.c:1429:14:
           | 1429 |          pid = parsedPid;
           |      |          ~~~~^~~~~~~~~~~
           |      |              |
           |      |              (13) ...to here
           |......
           | 1433 |       if (parent && pid == Process_getPid(parent))
           |      |          ~    
           |      |          |
           |      |          (14) following ‘false’ branch (when ‘parent’ is
NULL)...
           |......
           | 1437 |       int procFd = openat(dirFd, entry->d_name, O_RDONLY |
O_DIRECTORY | O_NOFOLLOW);
           |      |                                  ~~~~~~~~~~~~~
           |      |                                       |
           |      |                                       (15) ...to here
           |
         ‘LinuxProcessTable_recurseProcTree’: event 16
           |
           |linux/LinuxProcessTable.c:1438:10:
           | 1438 |       if (procFd < 0)
           |      |          ^
           |      |          |
           |      |          (16) following ‘false’ branch (when ‘procFd >=
0’)...
           |
         ‘LinuxProcessTable_recurseProcTree’: events 17-20
           |
           |linux/LinuxProcessTable.c:1446:23:
           | 1446 |       Process* proc = ProcessTable_getProcess(pt, pid,
&preExisting, LinuxProcess_new);
           |      |                      
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |                       |
           |      |                       (17) ...to here
           |......
           | 1449 |       Process_setThreadGroup(proc, parent ?
Process_getPid(parent) : pid);
           |      |      
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |       |
           |      |       (18) following ‘false’ branch (when ‘parent’ is
NULL)...
           |      |       (19) ...to here
           |......
           | 1452 |       LinuxProcessTable_recurseProcTree(this, procFd,
lhost, "task", proc);
           |      |      
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |       |
           |      |       (20) calling ‘LinuxProcessTable_recurseProcTree’ from
‘LinuxProcessTable_recurseProcTree’
           |
           +--> ‘LinuxProcessTable_recurseProcTree’: event 21
                  |
                  |linux/LinuxProcessTable.c:1375:12:
                  | 1375 | static bool
LinuxProcessTable_recurseProcTree(LinuxProcessTable* this, openat_arg_t
parentFd, const LinuxMachine* lhost, const char* dirname, const Process*
parent) {
                  |      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  |      |            |
                  |      |            (21) entry to
‘LinuxProcessTable_recurseProcTree’
                  |
                ‘LinuxProcessTable_recurseProcTree’: event 22
                  |
                  |linux/LinuxProcessTable.c:1387:7:
                  | 1387 |    if (dirFd < 0)
                  |      |       ^
                  |      |       |
                  |      |       (22) following ‘false’ branch (when ‘dirFd >=
0’)...
                  |
                ‘LinuxProcessTable_recurseProcTree’: events 23-24
                  |
                  |linux/LinuxProcessTable.c:1389:15:
                  | 1389 |    DIR* dir = fdopendir(dirFd);
                  |      |               ^~~~~~~~~~~~~~~~
                  |      |               |
                  |      |               (23) ...to here
                  |......
                  | 1395 |    if (!dir) {
                  |      |       ~        
                  |      |       |
                  |      |       (24) following ‘false’ branch (when ‘dir’ is
non-NULL)...
                  |
                ‘LinuxProcessTable_recurseProcTree’: event 25
                  |
                  |linux/LinuxProcessTable.c:1400:14:
                  | 1400 |    const bool hideKernelThreads =
settings->hideKernelThreads;
                  |      |              ^~~~~~~~~~~~~~~~~
                  |      |              |
                  |      |              (25) ...to here
                  |
                ‘LinuxProcessTable_recurseProcTree’: event 26
                  |
                  |linux/LinuxProcessTable.c:1403:34:
                  | 1403 |    while ((entry = readdir(dir)) != NULL) {
                  |
                ‘LinuxProcessTable_recurseProcTree’: event 27
                  |
                  |linux/LinuxProcessTable.c:1404:19:
                  | 1404 |       const char* name = entry->d_name;
                  |      |                   ^~~~
                  |      |                   |
                  |      |                   (27) ...to here
                  |
                ‘LinuxProcessTable_recurseProcTree’: events 28-30
                  |
                  |linux/LinuxProcessTable.c:1418:10:
                  | 1418 |       if (name[0] < '0' || name[0] > '9') {
                  |      |          ^
                  |      |          |
                  |      |          (28) following ‘false’ branch...
                  |......
                  | 1426 |          unsigned long parsedPid = strtoul(name,
&endptr, 10);
                  |      |                                   
~~~~~~~~~~~~~~~~~~~~~~~~~~
                  |      |                                    |
                  |      |                                    (29) ...to here
                  | 1427 |          if (parsedPid == 0 || parsedPid ==
ULONG_MAX || *endptr != '\0')
                  |      |             ~
                  |      |             |
                  |      |             (30) following ‘false’ branch...
                  |
                ‘LinuxProcessTable_recurseProcTree’: events 31-35
                  |
                  |linux/LinuxProcessTable.c:1429:14:
                  | 1429 |          pid = parsedPid;
                  |      |          ~~~~^~~~~~~~~~~
                  |      |              |
                  |      |              (31) ...to here
                  |......
                  | 1433 |       if (parent && pid == Process_getPid(parent))
                  |      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  |      |          |       |         |
                  |      |          |       |         (33) ...to here
                  |      |          |       (34) following ‘false’ branch...
                  |      |          (32) following ‘true’ branch (when ‘parent’
is non-NULL)...
                  |......
                  | 1437 |       int procFd = openat(dirFd, entry->d_name,
O_RDONLY | O_DIRECTORY | O_NOFOLLOW);
                  |      |                                  ~~~~~~~~~~~~~
                  |      |                                       |
                  |      |                                       (35) ...to
here
                  |
                ‘LinuxProcessTable_recurseProcTree’: event 36
                  |
                  |linux/LinuxProcessTable.c:1438:10:
                  | 1438 |       if (procFd < 0)
                  |      |          ^
                  |      |          |
                  |      |          (36) following ‘false’ branch (when ‘procFd
>= 0’)...
                  |
                ‘LinuxProcessTable_recurseProcTree’: events 37-39
                  |
                  |linux/LinuxProcessTable.c:1446:23:
                  | 1446 |       Process* proc = ProcessTable_getProcess(pt,
pid, &preExisting, LinuxProcess_new);
                  |      |                      
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  |      |                       |
                  |      |                       (37) ...to here
                  |......
                  | 1449 |       Process_setThreadGroup(proc, parent ?
Process_getPid(parent) : pid);
                  |      |      
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  |      |       |                                     |
                  |      |       |                                     (39)
...to here
                  |      |       (38) following ‘true’ branch (when ‘parent’ is
non-NULL)...
                  |
                ‘LinuxProcessTable_recurseProcTree’: event 40
                  |
                  |linux/LinuxProcessTable.c:1487:10:
                  | 1487 |       if (!LinuxProcessTable_readStatmFile(lp,
procFd, lhost))
                  |      |          ^
                  |      |          |
                  |      |          (40) following ‘false’ branch...
                  |
                ‘LinuxProcessTable_recurseProcTree’: events 41-46
                  |
                  |linux/LinuxProcessTable.c:1491:14:
                  | 1491 |          bool prev = proc->usesDeletedLib;
                  |      |              ^~~~
                  |      |              |
                  |      |              (41) ...to here
                  | 1492 | 
                  | 1493 |          if (!proc->isKernelThread &&
!proc->isUserlandThread &&
                  |      |             ~ 
                  |      |             |
                  |      |             (42) following ‘true’ branch...
                  | 1494 |              ((ss->flags &
PROCESS_FLAG_LINUX_LRS_FIX) || (settings->highlightDeletedExe &&
!proc->procExeDeleted && isOlderThan(proc, 10)))) {
                  |      |                ~~~~~~~~~
                  |      |                  |
                  |      |                  (43) ...to here
                  |......
                  | 1501 |             if (passedTimeInMs > recheck) {
                  |      |                ~
                  |      |                |
                  |      |                (44) following ‘true’ branch (when
‘passedTimeInMs > recheck’)...
                  | 1502 |                lp->last_mlrs_calctime =
host->realtimeMs;
                  |      |                                        
~~~~~~~~~~~~~~~~
                  |      |                                             |
                  |      |                                             (45)
...to here
                  | 1503 |                LinuxProcessTable_readMaps(lp,
procFd, lhost, ss->flags & PROCESS_FLAG_LINUX_LRS_FIX,
settings->highlightDeletedExe);
                  |      |               
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  |      |                |
                  |      |                (46) calling
‘LinuxProcessTable_readMaps’ from ‘LinuxProcessTable_recurseProcTree’
                  |
                  +--> ‘LinuxProcessTable_readMaps’: event 47
                         |
                         |linux/LinuxProcessTable.c:574:13:
                         |  574 | static void
LinuxProcessTable_readMaps(LinuxProcess* process, openat_arg_t procFd, const
LinuxMachine* host, bool calcSize, bool checkDeletedLib) {
                         |      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~
                         |      |             |
                         |      |             (47) entry to
‘LinuxProcessTable_readMaps’
                         |
                       ‘LinuxProcessTable_readMaps’: event 48
                         |
                         |linux/LinuxProcessTable.c:579:21:
                         |  579 |    FILE* mapsfile = fopenat(procFd, "maps",
"r");
                         |      |                    
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                         |      |                     |
                         |      |                     (48) calling ‘fopenat’
from ‘LinuxProcessTable_readMaps’
                         |
                         +--> ‘fopenat’: event 49
                                |
                                |linux/LinuxProcessTable.c:69:14:
                                |   69 | static FILE* fopenat(openat_arg_t
openatArg, const char* pathname, const char* mode) {
                                |      |              ^~~~~~~
                                |      |              |
                                |      |              (49) entry to ‘fopenat’
                                |
                              ‘fopenat’: event 50
                                |
                                |linux/LinuxProcessTable.c:73:7:
                                |   73 |    if (fd < 0)
                                |      |       ^
                                |      |       |
                                |      |       (50) following ‘false’ branch
(when ‘fd >= 0’)...
                                |
                              ‘fopenat’: events 51-55
                                |
                                |linux/LinuxProcessTable.c:76:19:
                                |   76 |    FILE* stream = fdopen(fd, mode);
                                |      |                   ^~~~~~~~~~~~~~~~
                                |      |                   |
                                |      |                   (51) ...to here
                                |      |                   (52) allocated here
                                |   77 |    if (!stream)
                                |      |       ~            
                                |      |       |
                                |      |       (53) assuming ‘stream’ is
non-NULL
                                |      |       (54) following ‘false’ branch
(when ‘stream’ is non-NULL)...
                                |......
                                |   80 |    return stream;
                                |      |           ~~~~~~   
                                |      |           |
                                |      |           (55) ...to here
                                |
                         <------+
                         |
                       ‘LinuxProcessTable_readMaps’: events 56-59
                         |
                         |linux/LinuxProcessTable.c:579:21:
                         |  579 |    FILE* mapsfile = fopenat(procFd, "maps",
"r");
                         |      |                    
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                         |      |                     |
                         |      |                     (56) returning to
‘LinuxProcessTable_readMaps’ from ‘fopenat’
                         |  580 |    if (!mapsfile)
                         |      |       ~              
                         |      |       |
                         |      |       (57) following ‘true’ branch (when
‘mapsfile’ is NULL)...
                         |  581 |       return;
                         |      |       ~~~~~~         
                         |      |       |
                         |      |       (58) ...to here
                         |      |       (59) ‘mapsfile’ leaks here; was
allocated at (52)
                         |
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-D' 'HAVE_CONFIG_H' '-I' '.' '-D'
'NDEBUG' '-std=c99' '-Wpedantic' '-D' '_DEFAULT_SOURCE' '-D'
'_XOPEN_SOURCE=600' '-I' '/usr/include/libnl3' '-I' '/usr/include/libnl3'
'-Wall' '-Wcast-align' '-Wcast-qual' '-Wextra' '-Wfloat-equal' '-Wformat=2'
'-Winit-self' '-Wsuggest-attribute=format' '-Wsuggest-attribute=noreturn'
'-Wmissing-prototypes' '-Wpointer-arith' '-Wshadow' '-Wstrict-prototypes'
'-Wundef' '-Wunused' '-Wwrite-strings' '-Wnull-dereference' '-D'
'_XOPEN_SOURCE_EXTENDED' '-D' 'SYSCONFDIR="/usr/local/etc"' '-I' './linux'
'-fanalyzer' '-Wanalyzer-infinite-loop' '-MT' 'linux/LinuxProcessTable.o' '-MD'
'-MP' '-MF' 'linux/.deps/LinuxProcessTable.Tpo' '-c' '-o'
'linux/LinuxProcessTable.o' '-mtune=generic' '-march=x86-64' '-dumpdir'
'linux/'
 as -v -I . -I /usr/include/libnl3 -I /usr/include/libnl3 -I ./linux --64 -o
linux/LinuxProcessTable.o linux/LinuxProcessTable.s
GNU assembler version 2.42 (x86_64-linux-gnu) using BFD version (GNU Binutils
for Ubuntu) 2.42
COMPILER_PATH=/usr/libexec/gcc/x86_64-linux-gnu/14/:/usr/libexec/gcc/x86_64-linux-gnu/14/:/usr/libexec/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/14/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/14/:/usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/14/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/14/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-D' 'HAVE_CONFIG_H' '-I' '.' '-D'
'NDEBUG' '-std=c99' '-Wpedantic' '-D' '_DEFAULT_SOURCE' '-D'
'_XOPEN_SOURCE=600' '-I' '/usr/include/libnl3' '-I' '/usr/include/libnl3'
'-Wall' '-Wcast-align' '-Wcast-qual' '-Wextra' '-Wfloat-equal' '-Wformat=2'
'-Winit-self' '-Wsuggest-attribute=format' '-Wsuggest-attribute=noreturn'
'-Wmissing-prototypes' '-Wpointer-arith' '-Wshadow' '-Wstrict-prototypes'
'-Wundef' '-Wunused' '-Wwrite-strings' '-Wnull-dereference' '-D'
'_XOPEN_SOURCE_EXTENDED' '-D' 'SYSCONFDIR="/usr/local/etc"' '-I' './linux'
'-fanalyzer' '-Wanalyzer-infinite-loop' '-MT' 'linux/LinuxProcessTable.o' '-MD'
'-MP' '-MF' 'linux/.deps/LinuxProcessTable.Tpo' '-c' '-o'
'linux/LinuxProcessTable.o' '-mtune=generic' '-march=x86-64' '-dumpdir'
'linux/LinuxProcessTable.'
```

* Preprocessed Source File: see attachment

* Additional remarks:

- The original source is based on the htop upstream commit ef6658c22d2f8a89.
- If anything is missing or needs further clarification, feel free to ask.

Reply via email to