Getting crash when using notarytool on Github hosted osx build agents

When I run notarytool submit in my github workflow, I get what appears to be some kind of segmentation fault.

Here's a direct link to the exception output: https://github.com/recyclarr/recyclarr/actions/runs/6594346352/job/17918152266#step:6:43

My project is open source, so you can also view the shell script I use in the workflow itself: https://github.com/recyclarr/recyclarr/blob/update-notary-tool/ci/notarize.sh

The script above contains this:

#!/usr/bin/env bash
set -xe

user="$1"
pass="$2"
teamId="$3"
archivePath="$4"

function submit() {
  xcrun notarytool submit --wait \
    --apple-id "$user" \
    --password "$pass" \
    --team-id "$teamId" \
    recyclarr.zip | \
    awk '/id: / { print $2;exit; }'
}

function log() {
  xcrun notarytool log \
    --apple-id "$user" \
    --password "$pass" \
    --team-id "$teamId" \
    "$1"
}

tar -cvf recyclarr.tar "$archivePath"
zip recyclarr.zip recyclarr.tar
submissionId="$(submit)"
rm recyclarr.zip recyclarr.tar

if [[ -z "$submissionId" ]]; then
  exit 1
fi

echo "Submission ID: $submissionId"

until log "$submissionId"
do
  sleep 2
done

The error (from the workflow run) is:

2023-10-21 01:24:18.817 notarytool[4894:25434] *** Terminating app due to uncaught exception 'NSFileHandleOperationException', reason: '*** -[_NSStdIOFileHandle writeData:]: Broken pipe'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007ff8106c4773 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007ff810424bc3 objc_exception_throw + 48
	2   Foundation                          0x00007ff8115b5962 -[NSConcreteFileHandle readDataUpToLength:error:] + 0
	3   Foundation                          0x00007ff811497590 -[NSConcreteFileHandle writeData:] + 263
	4   notarytool                          0x000000010bcff026 notarytool + 462886
	5   notarytool                          0x000000010bcb780d notarytool + 169997
	6   notarytool                          0x000000010bcd37c6 notarytool + 284614
	7   notarytool                          0x000000010bcea719 notarytool + 378649
	8   notarytool                          0x000000010bcd3d19 notarytool + 285977
	9   notarytool                          0x000000010bcd2a4e notarytool + 281166
	10  notarytool                          0x000000010bcd5009 notarytool + 290825
	11  notarytool                          0x000000010bc8fe66 notarytool + 7782
	12  dyld                                0x000000011781b52e start + 462
)
libc++abi: terminating with uncaught exception of type NSException

I do not get this error when I run this script directly on my 2023 MBP. It only appears to happen in my github workflow.

Is this a bug in notarytool? Notarization appears to still complete, and I also get a submission ID I can use for the notarytool log command I run after.

Answered by DTS Engineer in 769486022

'*** -[_NSStdIOFileHandle writeData:]: Broken pipe'

That error suggests that notarytool was writing to stdout or stderr and that write failed with EPIPE. This means that the far end of the pipe was closed.

Looking at your script it seems that you redirect stdout but not stderr, which suggests that stderr is the problem. However, seeing as this is reproducible you can check what’s going on. Redirect both stdout and stderr to temporary files and see if that prevents this failure. Then look at the files to see what being emitted.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

'*** -[_NSStdIOFileHandle writeData:]: Broken pipe'

That error suggests that notarytool was writing to stdout or stderr and that write failed with EPIPE. This means that the far end of the pipe was closed.

Looking at your script it seems that you redirect stdout but not stderr, which suggests that stderr is the problem. However, seeing as this is reproducible you can check what’s going on. Redirect both stdout and stderr to temporary files and see if that prevents this failure. Then look at the files to see what being emitted.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Getting crash when using notarytool on Github hosted osx build agents
 
 
Q