'top' command randomly crashes

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 7
  • procps-ng-3.3.10-17.el7_5.2

Issue

  • 'top' command randomly crashes and generates a core file.

Resolution

Update to procps-ng-3.3.10-17.el7_5.3 shipped with Advisory RHBA-2019:2567 or newer.

Root Cause

Previously, if the top program from procps-ng package was run in batch mode on heavy-loaded system, it tend to get killed by a termination signal, which, during exit phase of the program, caused segmentation fault and generation of core dump. This updates contains a fix mitigating and preventing mentioned issue.

Diagnostic Steps

  • Backtrace looks like this
#0  0x00007f71cdd6d8f1 in __GI__IO_putc (c=10, fp=0x7f71ce0bd400 <_IO_2_1_stdout_>) at putc.c:31
#1  0x00007f71ce2dd30a in tputs () from /lib64/libtinfo.so.5
#2  0x00000000004055c2 in bye_bye (str=str@entry=0x0) at top.c:563
#3  0x0000000000406b3f in sig_endpgm (dont_care_sig=<optimized out>) at top.c:625
#4  <signal handler called>
#5  0x00007f71cddef087 in munmap () at ../sysdeps/unix/syscall-template.S:81
#6  0x00007f71cdd72b62 in __GI__IO_setb (f=f@entry=0x7f71ce0bd400 <_IO_2_1_stdout_>, b=b@entry=0x0, eb=eb@entry=0x0, a=a@entry=0) at genops.c:402
#7  0x00007f71cdd70f40 in _IO_new_file_close_it (fp=fp@entry=0x7f71ce0bd400 <_IO_2_1_stdout_>) at fileops.c:194
#8  0x00007f71cdd64018 in _IO_new_fclose (fp=0x7f71ce0bd400 <_IO_2_1_stdout_>) at iofclose.c:59
#9  0x0000000000411131 in close_stream (stream=0x7f71ce0bd400 <_IO_2_1_stdout_>) at ../lib/fileutils.c:25
#10 0x00000000004111ad in close_stdout () at ../lib/fileutils.c:37
#11 0x00007f71cdd2fb69 in __run_exit_handlers (status=status@entry=0, listp=0x7f71ce0bc6c8 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true) at exit.c:77
#12 0x00007f71cdd2fbb7 in __GI_exit (status=status@entry=0) at exit.c:99
#13 0x00000000004055b8 in bye_bye (str=str@entry=0x0) at top.c:564
#14 0x0000000000402f2c in do_key (ch=<optimized out>) at top.c:4987
#15 main (dont_care_argc=<optimized out>, argv=<optimized out>) at top.c:5721
  • Code is spwaning top from a loop, in batch mode, with a small timeout (-d option), and one iteration (-n option), from third party code, to fetch some information from running processes.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments