Frame capture crashes Catalina

I am currently porting an OpenGL rendering backend to Metal (on macOS).
100% repro:
1. Press run App in Xcode.

2. Press frame capture button.

3. A correct looking view appears. [immediately]

4. The mouse pointer turns into the rainbow ball. [immediately]

5. The mouse pointer disappears. [after 5-15 seconds]

6. The external screen shuts off. [after another 15-30 seconds]
7. The system reboots. [after about 1-3 minutes]

It's very possible that I am sending some broken data down the command queue,
but

a) from what I see it looks exactly identical to the capture from the game template

b) I see (partially) correct render results when not capturing

c) Writing slightly broken metal code shouldn't crash the system
Any idea what I might be doing wrong?

Replies

Writing slightly broken metal code does, in fact, crash the system.
I've done this a few times recently in my exploration of Metal. I'm trying to remember my mistakes which did this...

Really bad values for thread group sizes will do this, I think.

This is an unfortunate problem that you're experiencing and we'd like to help. It might be possible to obtain insights into the problem by enabling shader and API validation in Xcode. You may also want to attempt disabling "profile after capture" in the scheme settings.

The team would also like to investigate this problem further. In some cases, the GPU trace file generated will be stored in a temporary location, even if your machine encountered a problem. You can find if this is the case by running the following command in the Terminal: find /private/var/folders/ -type d -name "*.gputrace" -print0 | xargs -0. If the file is there, we would appreciate if you could provide it to us via Feedback Assistant. A sysdiagnose would also help us conduct an investigation and determine the cause of the issue.