Public bug reported:

test_add_proc_info fails with the parent cmdline content:

```
       self.assertEqual(pr["ProcCmdline"], f"{catcmd} /foo\\ bar \\\\h \\\\\\ 
\\\\ -")
E       AssertionError: 'python3 -m pytest -ra -v -m not\\ require[37 
chars]ion/' != '/usr/bin/gnucat /foo\\ bar \\\\h \\\\\\ \\\\ -'
E       - python3 -m pytest -ra -v -m not\ requires_internet tests/unit/ 
tests/integration/
E       + /usr/bin/gnucat /foo\ bar \\h \\\ \\ -
```

1. When `subprocess.Popen` spawns a process, it first calls `fork()`
before calling `execve()`.

2. Immediately after `fork()`, the child process shares the parent's
memory image.

3. During this brief window (before `execve()` completes),
`/proc/{pid}/cmdline` contains the parent's command line.

4. The `wait_for_proc_cmdline` method checks if `/proc/{pid}/cmdline`
has content. Because the parent's cmdline is non-empty, it return
prematurely before `execve()` finishes replacing the process.

5. Apport then reads `/proc/{pid}/cmdline` while it still holds pytest's
command line.

Example failure on s390x:
https://autopkgtest.ubuntu.com/results/autopkgtest-
stonking/stonking/s390x/a/apport/20260725_070814_3faa8@/log.gz

** Affects: apport
     Importance: Undecided
         Status: New

** Affects: apport (Ubuntu)
     Importance: Undecided
         Status: New

** Also affects: apport
   Importance: Undecided
       Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2161888

Title:
  test_add_proc_info fails with parent cmdline content

To manage notifications about this bug go to:
https://bugs.launchpad.net/apport/+bug/2161888/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to