Commit Graph

2389 Commits

Author SHA1 Message Date
Daniel Lange
393330239e Small editorial fixes to ChangeLog 2021-08-27 09:31:06 +02:00
Nathan Scott
d2c34259b4 Remove trailing whitespace in changelog for CI checks 2021-08-27 12:19:50 +10:00
Nathan Scott
858ad8029d Update configure to reflect rc1 in the version 2021-08-27 12:14:23 +10:00
Nathan Scott
6876a4b136 Update ChangeLog 2021-08-27 12:11:22 +10:00
Daniel Lange
da7a369fa8 Merge branch 'shorten_crash_report' of cgzones/htop, rebased by BenBE 2021-08-26 19:31:50 +02:00
Christian Göttsche
4ed3ab5c2c Shorten crash output to fit on screen 2021-08-26 14:09:39 +02:00
Daniel Lange
088dc5b9a7 Remove license excemption for PLPA and update GPL-2 license text
The Portable Linux Processor Affinity (PLPA) project has been depreciated in
favour of the Portable Hardware Locality (hwloc) project. So the license
exception present in previous versions of htop is obsolete and thus removed.

The text of COPYING has been updated to the latest upstream license text
of GPL-2 from the Free Software Foundation, Inc. (FSF).
There are only editorial changes like line wrapping, removing page breaks,
updating the "19yy" to "<year>" and changing the FSF address.
2021-08-26 11:37:36 +02:00
Benny Baumann
16faf82739 Clarify naming of Platform_nanosecondsPerSchedulerTick 2021-08-25 20:45:00 +02:00
Daniel Lange
df17374a92 Merge branch 'refactor-Darwin-platform-unit-conversion-helpers' of amomchilov/htop 2021-08-25 19:15:17 +02:00
Alexander Momchilov
59d0c5b26a Refactor Darwin platform unit conversion helpers 2021-08-25 11:55:05 -04:00
Daniel Lange
fa48c484cc Merge branch 'fix-macOS-time-calculations' of amomchilov/htop 2021-08-25 17:07:06 +02:00
Christian Göttsche
a5e2eff5e9 configure: resolve autotools 2.70 deprecation warnings
configure.ac:72: warning: The macro `AC_PROG_CC_C99' is obsolete.
    configure.ac:72: You should run autoupdate.
    ./lib/autoconf/c.m4:1659: AC_PROG_CC_C99 is expanded from...
    configure.ac:72: the top level
    configure.ac:134: warning: The macro `AC_HEADER_STDC' is obsolete.
    configure.ac:134: You should run autoupdate.
    ./lib/autoconf/headers.m4:704: AC_HEADER_STDC is expanded from...
    configure.ac:134: the top level
2021-08-25 13:16:40 +02:00
Christian Göttsche
2bf626c4e4 IWYU update 2021-08-25 09:54:30 +02:00
Christian Göttsche
fecf093367 IWYU: add two header rules 2021-08-25 09:54:30 +02:00
Christian Göttsche
c243db0b2c XUtils: move implementation of String_contains_i out of header file
The function strcasestr(3) is only available if _GNU_SOURCE is defined.
If any file includes <string.h> before declaring _GNU_SOURCE, e.g by
including "config.h", compilation fails with the following error:

    In file included from ColumnsPanel.c:8:
    In file included from ./ColumnsPanel.h:12:
    In file included from ./Panel.h:13:
    In file included from ./CRT.h:16:
    In file included from ./Settings.h:17:
    In file included from ./Process.h:15:
    In file included from ./Object.h:17:
    ./XUtils.h:42:11: error: implicit declaration of function 'strcasestr' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
       return strcasestr(s1, s2) != NULL;
              ^
    ./XUtils.h:42:11: note: did you mean 'strcasecmp'?
    /usr/include/strings.h:116:12: note: 'strcasecmp' declared here
    extern int strcasecmp (const char *__s1, const char *__s2)
               ^

Move the implementation to avoid unnecessary includes.
Since LTO is quite common and stable performance should not be impacted
if used.
2021-08-25 09:54:30 +02:00
Daniel Lange
a18018ed48 Merge branch 'hlayout_id' of cgzones/htop 2021-08-24 20:43:18 +02:00
Christian Göttsche
db076b9c8e HeaderLayout: save name in configuration
Use a name in the user configuration file instead of the compile
time enum value, so that future reorderings or insertions do not change
the user selected layout.
2021-08-24 20:27:59 +02:00
Christian Göttsche
0679e9f45e Unsupported: update platform 2021-08-24 20:23:03 +02:00
Alexander Momchilov
7a4d6fa409 Style touch-ups 2021-08-23 10:37:49 -04:00
Alexander Momchilov
5b4d63d1be Fix macOS CPU time calculations 2021-08-23 10:37:49 -04:00
Daniel Lange
ec2307688e Merge branch 'header_fmt' of cgzones/htop 2021-08-23 14:56:05 +02:00
Daniel Lange
6d10736a64 Merge branch 'config_versions' of fasterit/htop 2021-08-23 14:53:24 +02:00
Daniel Lange
711a7aacb0 Tiny cleanup from review comments 2021-08-23 14:50:46 +02:00
Daniel Lange
a912512ac9 Simplify delay.tv_usec calculation from BenBE
Closes #761
2021-08-23 10:42:08 +02:00
Daniel Lange
35d94a5ae5 Apply approved warning message suggested by nathans 2021-08-23 08:58:14 +02:00
Christian Göttsche
ccb756d3c7 Widen integer type before multiplication
Meter.c:320:71: warning: performing an implicit widening conversion to type '__suseconds_t' (aka 'long') of a multiplication performed in type 'int' [bugprone-implicit-    widening-of-multiplication-result]
          struct timeval delay = { .tv_sec = globalDelay / 10, .tv_usec = (globalDelay - ((globalDelay / 10) * 10)) * 100000 };
                                                                          ^
2021-08-22 17:53:21 +02:00
Christian Göttsche
5dec9475bb Use break inside loop with false condition
Found by clang-tidy.

    home/christian/Coding/workspaces/htop/Process.c:505:13: warning: 'continue' in loop with false condition is equivalent to 'break' [bugprone-terminating-continue]
               WRITE_HIGHLIGHT(0, strlen(procComm), commAttr, CMDLINE_HIGHLIGHT_FLAG_COMM);
               ^
    /home/christian/Coding/workspaces/htop/Process.c:461:13: note: expanded from macro 'WRITE_HIGHLIGHT'
                continue;                                                                         \
                ^
2021-08-22 17:53:21 +02:00
Christian Göttsche
c3746dc901 Align parameters names between function declaration and definition
Found by clang-tidy.
2021-08-22 17:53:21 +02:00
Benny Baumann
6e6334e603 Simplify adding pages in one place 2021-08-22 16:15:59 +02:00
Christian Göttsche
9060a4179d Add option to change Header layout 2021-08-22 16:15:59 +02:00
Benny Baumann
7269faf651 Only request selection index in ColorsPanel when needed 2021-08-22 15:22:27 +02:00
Benny Baumann
7146059645 Removed unused field in ColorsPanel 2021-08-22 15:21:52 +02:00
Christian Göttsche
cf45a5d02b MemorySwapMeter: use full width on odd total width 2021-08-22 14:51:13 +02:00
Christian Göttsche
a905c45195 Meter: update documentation to match Doxygen style 2021-08-22 14:50:52 +02:00
Christian Göttsche
9df0f62859 Linux: do not scan frequency for inactive CPUs 2021-08-22 14:50:38 +02:00
Christian Göttsche
68f2bfea61 Abstract resize handling by adding a new Htop reaction 2021-08-22 10:40:59 +02:00
Christian Göttsche
b9e69223d0 ScreenManager: reduce ScreenManager_resize
The main change is the header hight being not included in y1.
This is important if a sub-manager gets resized, e.g. a resize while
editing the Settings or in a pickFromVector selection, and afterwards,
then the sub-manager is closed, the super-ScreenManager gets resized, it
uses the correct header hight.
The header hight might have been changed since the last resize of the
super-manager in the Settings by adding/removing some meters.

This fixes new meters being hidden after added at runtime after a resize
in the main window.
2021-08-22 10:40:59 +02:00
Christian Göttsche
edc3de7cb5 Action: specify implication in code not in comments 2021-08-22 10:40:59 +02:00
Daniel Lange
a9ddaccc63 Merge branch 'read-settings-defaults' of bjpbakker/htop 2021-08-18 14:47:16 +02:00
Daniel Lange
a0c244a163 Spell out virtualized 2021-08-18 14:01:25 +02:00
Christian Göttsche
f886759022 Meter: limit LED mode by width
Stop displaying LED-mode if maximum width is reached.
2021-08-17 10:36:10 +02:00
Christian Göttsche
b965417bf7 Add combined memory and swap meter
Closes: #699
2021-08-17 10:36:10 +02:00
Nathan Scott
3f727d4720
Merge pull request #747 from natoscott/coverity
Coverity scan updates (minor)
2021-08-17 15:42:33 +10:00
Nathan Scott
d5ff5c48a8
Apply suggestions from code review
Co-authored-by: BenBE <BenBE@geshi.org>
2021-08-17 15:42:10 +10:00
Nathan Scott
c7f634ec21 PCP: ensure unsigned types used throughout CPU count detection
This cannot be negative in these code locations, but for the
purposes of static checking like Coverity scan make it clear
and used the same unsigned type as ProcessList.h for the CPU
count variable (matching PL activeCPUs and existingCPUs).
2021-08-17 14:41:55 +10:00
Nathan Scott
c401ac3a98 Ensure DynamicColumn hash lookups never see NULL pointers
This cannot happen in these code locations, but for the purposes
of static checkers like Coverity scan (and for future proofing),
add two more guards on NULL hash table entry pointers.
2021-08-17 14:41:40 +10:00
Sohaib
fefff80631 PCP: PCPMetric.[ch] Mdoule
Split the PCP Metric API (functions `Metric_*`) into their own module.
as @BenBE suggested.
2021-08-16 17:23:07 +02:00
Christian Göttsche
edafa26f9e Simplify Action_pickFromVector() width parameter usage
Pass one less instead of subtracting one inside the function.
2021-08-16 08:05:46 +02:00
Christian Göttsche
68460b25e3 Reset the signal handlers at program exit
The signal handler will access the Settings struct, which gets freed at
normal program finalization.

When using leak sanitizers with ASAN_OPTIONS=abort_on_error=1, which
runs after program termination, any leak causes SIGABRT to be raised,
calling the crash handler, which will derefernce the freed Settings.

    ==44741==ERROR: AddressSanitizer: heap-use-after-free on address 0x60d000000080 at pc 0x0000005680df bp 0x7fffe335e960 sp 0x7fffe335e958
    READ of size 8 at 0x60d000000080 thread T0
        #0 0x5680de in Settings_write /home/christian/Coding/workspaces/htop/Settings.c:329:26
        #1 0x4f77b7 in CRT_handleSIGSEGV /home/christian/Coding/workspaces/htop/CRT.c:1020:4
        #2 0x7f8a1120c13f  (/lib/x86_64-linux-gnu/libpthread.so.0+0x1413f)
        #3 0x7f8a11042ce0 in __libc_signal_restore_set signal/../sysdeps/unix/sysv/linux/internal-signals.h:86:3
        #4 0x7f8a11042ce0 in raise signal/../sysdeps/unix/sysv/linux/raise.c:48:3
        #5 0x7f8a1102c536 in abort stdlib/abort.c:79:7
        #6 0x4c3db6 in __sanitizer::Abort() (/home/christian/Coding/workspaces/htop/htop+0x4c3db6)
        #7 0x4c2090 in __sanitizer::Die() (/home/christian/Coding/workspaces/htop/htop+0x4c2090)
        #8 0x4d0a17 in __lsan::HandleLeaks() (/home/christian/Coding/workspaces/htop/htop+0x4d0a17)
        #9 0x4cd950 in __lsan::DoLeakCheck() (/home/christian/Coding/workspaces/htop/htop+0x4cd950)
        #10 0x7f8a110454d6 in __run_exit_handlers stdlib/exit.c:108:8
        #11 0x7f8a11045679 in exit stdlib/exit.c:139:3
        #12 0x7f8a1102dd10 in __libc_start_main csu/../csu/libc-start.c:342:3
        #13 0x428a19 in _start (/home/christian/Coding/workspaces/htop/htop+0x428a19)

    0x60d000000080 is located 64 bytes inside of 144-byte region [0x60d000000040,0x60d0000000d0)
    freed by thread T0 here:
        #0 0x4a4f72 in free (/home/christian/Coding/workspaces/htop/htop+0x4a4f72)
        #1 0x566693 in Settings_delete /home/christian/Coding/workspaces/htop/Settings.c:32:4
        #2 0x4ede10 in CommandLine_run /home/christian/Coding/workspaces/htop/CommandLine.c:393:4
        #3 0x4d6f32 in main /home/christian/Coding/workspaces/htop/htop.c:15:11
        #4 0x7f8a1102dd09 in __libc_start_main csu/../csu/libc-start.c:308:16

    previously allocated by thread T0 here:
        #0 0x4a5372 in __interceptor_calloc (/home/christian/Coding/workspaces/htop/htop+0x4a5372)
        #1 0x57f61a in xCalloc /home/christian/Coding/workspaces/htop/XUtils.c:55:17
        #2 0x5688a6 in Settings_new /home/christian/Coding/workspaces/htop/Settings.c:392:21
        #3 0x4ecb57 in CommandLine_run /home/christian/Coding/workspaces/htop/CommandLine.c:303:25
        #4 0x4d6f32 in main /home/christian/Coding/workspaces/htop/htop.c:15:11
        #5 0x7f8a1102dd09 in __libc_start_main csu/../csu/libc-start.c:308:16

SUMMARY: AddressSanitizer: heap-use-after-free /home/christian/Coding/workspaces/htop/Settings.c:329:26 in Settings_write
2021-08-16 08:05:07 +02:00
Benny Baumann
b42c441ee0 Use proper metric to detect kernel threads
Querying kernel threads with `ps -o pid,lid,flags,state,lname -sp 0`
gives that kernel threads have state `K` and flags have mask `0x20000` set.
This corresponds to `LW_SYSTEM` in kernel which is mapped as `L_SYSTEM`/`P_SYSTEM` for userspace.
2021-08-16 08:03:57 +02:00