pstree reports "/proc/xxxx: No such file or directory"

Bug #1629839 reported by Barry Luijten
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
psmisc (Ubuntu)
Expired
Low
Unassigned

Bug Description

At random occasions, pstree returns "/proc/xxxx: No such file or directory" on stderr. No output on stdout is produced.
I can reproduce the problem using this script:

#!/bin/bash
for i in $(seq 1 1000); do
        unset p
        p=$(pstree -s -A $$ 2>/dev/null)
        if [ "$?" -ne "0" ]; then
                p=$(pstree -s -A $$ 2>/dev/null)
                echo "Retry: $p"
        fi
        sleep 0.02
done

I have seen this behavior in version 22.15 (shipped with Ubuntu 12.04 LTS, package version 22.15-2ubuntu1.2). The problem does not seem to occur on version 22.21 (shipped with Ubuntu 16.04 LTS).

Revision history for this message
Launchpad Janitor (janitor) wrote :

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

Changed in psmisc (Ubuntu):
status: New → Confirmed
Revision history for this message
Robie Basak (racb) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better.

Looks like this bug was reported and fixed upstream in https://sourceforge.net/p/psmisc/patches/34/

It does not appear to yet be fixed in Ubuntu or Debian. Since it is a race condition, it seems likely to me that you just happen to have not hit it in your testing on 16.04.

Since this is fixed upstream, the fix will eventually make its way to a future Ubuntu release. It doesn't seem important enough to me to be worth maintaining a delta in Ubuntu. But if you disagree, feel free to make your case here.

Changed in psmisc (Ubuntu):
status: Confirmed → Triaged
importance: Undecided → Low
Revision history for this message
Reinhard Neder (nederrbn) wrote :

This error still exists in Ubuntu 18.04 LTS in August 2019, three years later.
The pstree version is 23.1
On our local high performance system the pstree version is 22.20 and the error does occur frequently.
As of which pstree version should the bug have been fixed?

To make a case for the importance of this bug fix I need to do the following:
In parallel processing i use mpi. Unfortunately, within mpi a program cannot tell if the program was started as: "mpiexec -n 20 my_program" or serially as "my_program". By running a command line
"pstree -s -l -p PID" prior to initializing the MPI world, I could distinguish the two different start up modi.

Revision history for this message
Robie Basak (racb) wrote :

It looks like the upstream patch I identified was adopted in 23.0-1, and 18.04 shipped with 23.1-1 so included it. If you can still reproduce the bug, then perhaps that patch didn't fix it, and so no fix is currently available. If you can figure out how to fix the problem, please send the patch upstream for adoption. Unfortunately with only two people reporting themselves as affected by this bug since 2016, I don't think I can justify spending more time on this, but volunteers are welcome and I will be happy to provide guidance to get a fix landed in Ubuntu's development release if they can come forward with one that has been accepted upstream.

> Unfortunately, within mpi a program cannot tell if the program was started as: "mpiexec -n 20 my_program" or serially as "my_program". By running a command line
"pstree -s -l -p PID" prior to initializing the MPI world, I could distinguish the two different start up modi.

Can you not inspect argv[0]? In any case, you don't _need_ to use pstree for that. Examine /proc/PID/cmdline, or if you want to follow parent PIDs, you can use getppid(2) or call "ps" to follow that recursively. I appreciate that the latter is just a workaround for the bug in pstree, of course, but "workaround available" does qualify lower priority. In any case, a program calling pstree to determine how it itself was called seems like a horrible hack as it is.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

I think for openmpi the usual less hacky hack is to use the environment variable [1] availability right?

[1]: https://www.open-mpi.org/faq/?category=running#mpi-environmental-variables

Barry Luijten (striper)
description: updated
Revision history for this message
Barry Luijten (striper) wrote :

At the time of filing this bug report, I used to use pstree to determine if a script was called from cron or an interactive terminal, but I found a simpler solution by inspecting the $TERM environment variable.
I guess the number of "users affected" dropped by 1 ;)
Thanks for your updates guys.

Revision history for this message
Bryce Harrington (bryce) wrote :

Reinhard, please let us know if this is still an issue for you, otherwise I think this can be closed out.

Changed in psmisc (Ubuntu):
status: Triaged → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for psmisc (Ubuntu) because there has been no activity for 60 days.]

Changed in psmisc (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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