Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-19209

Agent2 panic: index out of range

    XMLWordPrintable

    Details

    • Team:
      Team INT
    • Sprint:
      Sprint 75 (Apr 2021), Sprint 76 (May 2021)
    • Story Points:
      0.5

      Description

      Steps to reproduce:

      1. Configure a host running Zabbix Agent 2 for process checks (kernel.maxproc seems a good candidate here)
      2. Put the host under stress, a large docker installation does the trick for me

      Result:

      Zabbix Agent 2 crashes with runtime error:

      Apr 05 12:54:16 emma.lummerland zabbix_agent2[609646]: panic: runtime error: index out of range [0] with length 0
      Apr 05 12:54:16 emma.lummerland zabbix_agent2[609646]: goroutine 150 [running]:
      Apr 05 12:54:16 emma.lummerland zabbix_agent2[609646]: zabbix.com/plugins/proc.getProcesses(0xe, 0xc00018e000, 0x1dc, 0x200, 0x0, 0x0)
      Apr 05 12:54:16 emma.lummerland zabbix_agent2[609646]:         /build/zabbix/src/zabbix-5.2.6/src/go/plugins/proc/procfs_linux.go:142 +0x93f
      Apr 05 12:54:16 emma.lummerland zabbix_agent2[609646]: zabbix.com/plugins/proc.(*PluginExport).Export(0x132f040, 0xc00019a4e0, 0x8, 0xc0001c8200, 0x5, 0x8, 0xef0ab8, 0xc0002ba0c0, 0x0, 0x0, ...)
      Apr 05 12:54:16 emma.lummerland zabbix_agent2[609646]:         /build/zabbix/src/zabbix-5.2.6/src/go/plugins/proc/proc_linux.go:497 +0x16c
      Apr 05 12:54:16 emma.lummerland zabbix_agent2[609646]: zabbix.com/internal/agent/scheduler.(*directExporterTask).perform.func1(0xc0002ba0c0, 0xeedd78, 0xc000328af0, 0xc000502080, 0x1f)
      Apr 05 12:54:16 emma.lummerland zabbix_agent2[609646]:         /build/zabbix/src/zabbix-5.2.6/src/go/internal/agent/scheduler/task.go:266 +0x47c
      Apr 05 12:54:16 emma.lummerland zabbix_agent2[609646]: created by zabbix.com/internal/agent/scheduler.(*directExporterTask).perform
      Apr 05 12:54:16 emma.lummerland zabbix_agent2[609646]:         /build/zabbix/src/zabbix-5.2.6/src/go/internal/agent/scheduler/task.go:250 +0x65
      Apr 05 12:54:16 emma.lummerland systemd[1]: zabbix-agent2.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
      

      The crash occurs reliably on two virtual hosts (VMs) at my provider. I was unable to reproduce it on a Raspberry Pi or on a VM running on a small AMD Geode CPU.

      Anyway, the crash output indicates that https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/src/go/plugins/proc/procfs_linux.go#142 still can fail due to empty slice even if f.Readdir(1) did not return an error - which should not happen in any case. I guess it should be sufficient to add a check for an empty entries slice in the if statement on that line and (loop) continue if either empty or !entries[0].IsDir()

      Expected:

      No crash...

        Attachments

          Activity

            People

            Assignee:
            esneiders Eriks Sneiders
            Reporter:
            Buzz T. Sebastian Gmeiner
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: