launchd and other system apps get stuck in uninterruptible wait after generating core dump

Hi!

I configured my system to collect core dumps on app crash, but it turned out that in some cases the system becomes unresponsive after a user app crashes.

I was unable to reproduce the issue crashing simple C or even C# (by .NET runtime) programs, but for example it always happens after crashes of our unit tests (NUnit framework, and .NET 7 runtime): the corresponding core file appears on the disk, but an attempt to copy/open that file hangs forever:

$ ls -la .../core.dotnet.5406.511
-r--------  1 ...  staff  30273536 Jan  2 09:19 .../core.dotnet.5406.511
$ cp /opt/buildAgent/temp/buildTmp/core.dotnet.5406.511 1
^C^C^C^C^C^C^C^C^C^C^Z(hangs)

And now at that time I cannot open Activity Monitor, or Console, or Terminal (they are just bouncing in the Dock), sw_vers command doesn't work (as well as lldb and sample), and according to ps they get stuck in an uninterruptible wait:

$ sw_vers
(hangs)^C
$ sudo lldb -p 5477
(hangs)^C
$ sudo sample -p 5477
(hangs)^C [Interrupted]
Not currently sampling -- exiting immediately.
$ ps ax | grep "  U"
    1   ??  Us     1:03.58 /sbin/launchd
 5406   ??  U      0:59.11 .../dotnet exec [...]
 5477 s000  U+     0:00.00 cp .../core.dotnet.5406.511 1
 5496 s001  S+     0:00.00 grep   U

After a reboot, the core file is not saved and everything works fine again until the same case:

$ ls -la .../core.dotnet.5406.511
-r--------  1 ...  staff  0 Jan  2 09:19 .../core.dotnet.5406.511

Just in case, here are the entitlements of dotnet:

$ codesign -d --entitlement :- .../dotnet
Executable=.../dotnet
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>com.apple.security.cs.allow-jit</key>
      <true/>
    <key>com.apple.security.cs.allow-dyld-environment-variables</key>
      <true/>
    <key>com.apple.security.cs.disable-library-validation</key>
      <true/>
    <key>com.apple.security.cs.debugger</key>
      <true/>
    <key>com.apple.security.get-task-allow</key>
      <true/>
  </dict>
</plist>

I didn't see this issue on macOS Catalina 10.15.7, is there anything I can help with?

-- .NET SDK 7.0.100 macOS Big Sur 11.7.1

launchd and other system apps get stuck in uninterruptible wait after generating core dump
 
 
Q