This bug has been migrated to another issue tracking site. It has been closed here and may no longer be being monitored.

If you would like to get updates for this issue, or to participate in it, you may do so at Red Hat Issue Tracker .
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2212314 - systemd deadlocks waiting for its child forever when receiving SIGQUIT signal
Summary: systemd deadlocks waiting for its child forever when receiving SIGQUIT signal
Keywords:
Status: CLOSED MIGRATED
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: systemd
Version: 8.8
Hardware: All
OS: Linux
high
high
Target Milestone: rc
: ---
Assignee: Michal Sekletar
QA Contact: Frantisek Sumsal
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-06-05 09:35 UTC by Renaud Métrich
Modified: 2023-09-21 15:15 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-09-21 15:15:04 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker   RHEL-6103 0 None Migrated None 2023-09-21 15:14:57 UTC
Red Hat Issue Tracker RHELPLAN-158954 0 None None None 2023-06-05 09:40:53 UTC

Description Renaud Métrich 2023-06-05 09:35:33 UTC
Description of problem:

We have a customer that could observe systemd not reaping any children, hence zombies accumulating.
The vmcore showed that PID 1 was waiting forever for a child it spawned, still named "systemd", the child being itself hanging in writing to a pipe.

We believe some SIGQUIT signal was sent to PID 1, which leads to exact same observation:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# kill -QUIT 1

# cat /proc/1/stack
[<0>] do_wait+0x165/0x2f0
[<0>] kernel_waitid+0x118/0x180
[<0>] __do_sys_waitid+0x120/0x130
[<0>] do_syscall_64+0x5b/0x1b0
[<0>] entry_SYSCALL_64_after_hwframe+0x61/0xc6

# cat /proc/2037/stack 
[<0>] pipe_wait+0x6c/0xc0
[<0>] pipe_write+0x16c/0x3f0
[<0>] new_sync_write+0x112/0x160
[<0>] __kernel_write+0x4f/0x100
[<0>] dump_emit+0x91/0xd0
[<0>] elf_core_dump+0x890/0xa50
[<0>] do_coredump+0x73f/0xf52
[<0>] get_signal+0x14f/0x870
[<0>] do_signal+0x36/0x690
[<0>] exit_to_usermode_loop+0x89/0x100
[<0>] do_syscall_64+0x19c/0x1b0
[<0>] entry_SYSCALL_64_after_hwframe+0x61/0xc6
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

The root cause for this is systemd, upon receiving SIGQUIT, will dump core.
To do that it spawns a child, then waits for it to terminate.
The child sends itself the SIGQUIT signal.

This triggers the core_pattern handler to execute and kernel to create a pipe for coredumping and send data to the pipe immediately.
The core_pattern handler executes, sends to /run/systemd/coredump Unix socket where the coredump service will read the coredump from (the pipe create by the kernel).

Normally systemd should spawns systemd-coredump instantiable service, which in turn reads from the pipe, but it cannot since it's waiting for its child to terminate.

--> Deadlock

Version-Release number of selected component (if applicable):

systemd-239

How reproducible:

Always

Steps to Reproduce:
1. Send SIGQUIT to PID 1

Actual results:

Deadlock of PID 1 and its child

Expected results:

PID 1 functional

Additional infos:

Because PID 1 is critical for RHEL systems, it has to be super robust.

Comment 1 Renaud Métrich 2023-06-05 09:47:07 UTC
It's very possible other scenarios but SIGQUIT can cause same deadlock.
Looking at the systemd code, I see this in particular:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
 801 void sigkill_wait(pid_t pid) {
 802         assert(pid > 1);
 803 
 804         if (kill(pid, SIGKILL) > 0)
 805                 (void) wait_for_terminate(pid, NULL);
 806 }

 819 void sigterm_wait(pid_t pid) {
 820         assert(pid > 1);
 821 
 822         if (kill_and_sigcont(pid, SIGTERM) > 0)
 823                 (void) wait_for_terminate(pid, NULL);
 824 }
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

sigterm_wait() is called by some DBus thing:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
1067 static void bus_kill_exec(sd_bus *bus) {
1068         if (pid_is_valid(bus->busexec_pid) > 0) {
1069                 sigterm_wait(bus->busexec_pid);
1070                 bus->busexec_pid = 0;
1071         }
1072 }
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

I don't know how to reproduce this code path, but I guess that if PID 1 sends a TERM to that other process, which in turn starts dumping core (because it didn't like receiving the signal), then same deadlock will happen.

Comment 2 David Tardon 2023-06-06 12:07:57 UTC
(In reply to Renaud Métrich from comment #1)
> I don't know how to reproduce this code path, but I guess that if PID 1
> sends a TERM to that other process, which in turn starts dumping core
> (because it didn't like receiving the signal), then same deadlock will
> happen.

This code path cannot be triggered in PID1 (or anywhere else in systemd codebase). It requires direct use of sd-bus API, like this:

int main(void) {
        sd_bus *bus;

        sd_bus_new(&bus);
        sd_bus_set_exec(bus, path, argv); // Sets bus->exec_path
        sd_bus_start(bus); // Starts the command in bus->exec_path and sets bus->busexec_pid accordingly
        sd_bus_close(bus); // Calls bus_kill_exec()
}

Comment 3 RHEL Program Management 2023-09-21 13:54:36 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 4 RHEL Program Management 2023-09-21 15:15:04 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.


Note You need to log in before you can comment on or make changes to this bug.