pgrep reports error "cannot allocate" when run without stack limit

Bug #1874824 reported by Sven Hartrumpf on 2020-04-24
38
This bug affects 8 people
Affects Status Importance Assigned to Milestone
procps (Debian)
New
Unknown
procps (Ubuntu)
Status tracked in Hirsute
Focal
Undecided
Unassigned
Groovy
Undecided
Unassigned
Hirsute
Undecided
Unassigned

Bug Description

If you have no stack limit (ulimit -S -s unlimited), any pgrep call will fail with an error:

> pgrep vim
pgrep: cannot allocate 4611686018427387903 bytes

If you have a high stack limit (e.g. ulimit -S -s 500000), pgrep is very slow:

> time pgrep vim
2196
real 8.48s user 8.40s syst 0.07s busy 99% rmem 253444

The relevant upstream bug report could be: https://gitlab.com/procps-ng/procps/-/issues/152
Archlinux bug report: https://bugs.archlinux.org/task/66093

procps:
  Installed: 2:3.3.16-1ubuntu2
  500 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages

Sven Hartrumpf (hartrumpf) wrote :

For the unlimited case, there is also Debian bug #955697 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=955697
Those bug reports do not mention the massive slowdown linear in stack limit.

Sven Hartrumpf (hartrumpf) wrote :

The problem is the same for other popular tools like pkill from the same package.

Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in procps (Ubuntu):
status: New → Confirmed
Sven Hartrumpf (hartrumpf) wrote :

Archlinux fixed this bug today, now in testing stage. Any news for Ubuntu?

Sven Hartrumpf (hartrumpf) wrote :

I installed procps-ng 3.3.16.49-ae4a myself on all our Ubuntu 20.04 computers. This fixed both problems, slow pgrep / pkill and crashing pgrep / pkill.

Changed in procps (Debian):
status: Unknown → New
Sven Hartrumpf (hartrumpf) wrote :

The Arch Linux fix appeared in Manjaro. I can confirm that it works on Manjaro machines.

Sven Hartrumpf (hartrumpf) wrote :

Even worse for Ubuntu 20.10 (procps 2:3.3.16-5ubuntu2). With a stack limit of 500000, almost 11 seconds for a simple pgrep; without stacklimit, immediate crash.

Hassan El Jacifi (waver) on 2020-11-11
tags: added: groovy
Vasilis (vasilis-vlachoudis) wrote :

It appeared today, after rebooting with the latest kernel, however I have not updated procps since some time now and it was working before

Sven Hartrumpf (hartrumpf) wrote :

Can the bug fix be applied for Ubuntu 21.04? Please.

On slow machines like a Raspberry 4 with stack limit 500000 (Ubuntu 20.10), a single pgrep call takes 17 seconds!

tags: added: hirsute
Robie Basak (racb) wrote :
tags: added: bitesize patch rls-hh-incoming
Changed in procps (Ubuntu):
status: Confirmed → Triaged
tags: added: fr-1174
tags: removed: rls-hh-incoming
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in procps (Ubuntu Focal):
status: New → Confirmed
Changed in procps (Ubuntu Groovy):
status: New → Confirmed
Luke Yeager (luke-yeager) wrote :

FWIW, I was able to apply bb96fc4295 cleanly to the current 20.04 package (2:3.3.16-1ubuntu2) and it works for me.

apt-get -y source procps && cd procps-*
curl -fSsL -o debian/patches/sc_arg_max https://gitlab.com/procps-ng/procps/-/commit/bb96fc4295.patch
echo sc_arg_max >>debian/patches/series
dch --local myorg 'Apply patch: "pgrep: check sanity of SC_ARG_MAX"'
debuild -us -uc -G -i -tc

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.