codesign failing with with 139 exit code

In last few days codesign failed multiple time to sign my apps. During the failure, codesign command was exiting with exit code of 139. The crash report of codesign tool shows SIGSEGV in com.apple.security.XPCTimeStampingService.

Knowing that codesign requires a connection to an Apple's time stamp server. I verified the network connection but everything was fine. Upon looking deep into the crash report, it seems that the dereference to unmapped memory triggered the crash at 0x0000000000000000, which is an invalid address, specifically a NULL pointer.

I'd be interested to know,
  • was there any ongoing issue with Apple's timestamp server?

  • or the issue is local to our development environment?


Failure date time:
24 May 2021 13:26:38
24 May 2021 10:57:22
24 May 2021 09:23:34
24 May 2021 08:50:33
24 May 2021 07:25:21
23 May 2021 16:30:33
21 May 2021 20:22:01

Crash dump:
Code Block
Process: codesign [50994]
Path: /usr/bin/codesign
Identifier: codesign
Version: 0.3
Code Type: X86-64 (Native)
Parent Process: java [14314]
Responsible: java [14314]
User ID: 501
Date/Time: 2021-05-21 23:42:02.514 +0000
OS Version: Mac OS X 10.15.7 (19H15)
Report Version: 12
Bridge OS Version: 5.3 (18P4556)
Anonymous UUID: B997C94F-E378-469A-B7D2-7BC95FA719A2
Sleep/Wake UUID: 7A0A3E14-6643-4943-B365-F3135B96BD17
Time Awake Since Boot: 590000 seconds
System Integrity Protection: enabled
Crashed Thread: 1 Dispatch queue: com.apple.security.XPCTimeStampingService
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [50994]
VM Regions Near 0:
-->
__TEXT 000000010d113000-000000010d12a000 [ 92K] r-x/r-x SM=COW /usr/bin/codesign
Application Specific Information:
dyld3 mode
Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff6d2f3e4e semaphore_timedwait_trap + 10
1 libdispatch.dylib 0x00007fff6d159b6b _dispatch_sema4_timedwait + 76
2 libdispatch.dylib 0x00007fff6d159f97 _dispatch_semaphore_wait_slow + 58
3 com.apple.security 0x00007fff3fd28491 SecCmsTSADefaultCallback + 1503
4 com.apple.security 0x00007fff3fd2d6cc nss_cms_encoder_notify + 3151
5 com.apple.security 0x00007fff3fbdc104 SEC_ASN1EncoderUpdate + 480
6 com.apple.security 0x00007fff3fd2e04a SecCmsEncoderFinish + 275
7 com.apple.security 0x00007fff3fd26d9f CMSEncoderCopyEncodedContent + 124
8 com.apple.security 0x00007fff3fd719d8 Security::CodeSigning::SecCodeSigner::Signer::signCodeDirectory(Security::CodeSigning::CodeDirectory const*, __CFDictionary const*, __CFArray const*) + 624
9 com.apple.security 0x00007fff3fd70031 Security::CodeSigning::SecCodeSigner::Signer::sign(unsigned int) + 10477
10 com.apple.security 0x00007fff3fd30691 Security::CodeSigning::SecCodeSigner::sign(Security::CodeSigning::SecStaticCode*, unsigned int) + 413
11 com.apple.security 0x00007fff3fd39127 SecCodeSignerAddSignatureWithErrors + 124
12 codesign 0x000000010d116773 0x10d113000 + 14195
13 codesign 0x000000010d114fec 0x10d113000 + 8172
14 libdyld.dylib 0x00007fff6d1b2cc9 start + 1
Thread 1 Crashed:: Dispatch queue: com.apple.security.XPCTimeStampingService
0 libxpc.dylib 0x00007fff6d3ec8e0 xpc_get_type + 10
1 libxpc.dylib 0x00007fff6d3ed494 xpc_data_get_length + 14
2 com.apple.security 0x00007fff3fd2894f __sendTSARequestWithXPC_block_invoke.23 + 421
3 libxpc.dylib 0x00007fff6d3f81ff _xpc_connection_reply_callout + 36
4 libxpc.dylib 0x00007fff6d3f8187 _xpc_connection_call_reply_async + 69
5 libdispatch.dylib 0x00007fff6d1596c2 _dispatch_client_callout3 + 8
6 libdispatch.dylib 0x00007fff6d17015d _dispatch_mach_msg_async_reply_invoke + 369
7 libdispatch.dylib 0x00007fff6d15eaf6 _dispatch_lane_serial_drain + 263
8 libdispatch.dylib 0x00007fff6d15f5d6 _dispatch_lane_invoke + 363
9 libdispatch.dylib 0x00007fff6d168c09 _dispatch_workloop_worker_thread + 596
10 libsystem_pthread.dylib 0x00007fff6d3b3a3d _pthread_wqthread + 290
11 libsystem_pthread.dylib 0x00007fff6d3b2b77 start_wqthread + 15
Thread 2:
0 libsystem_pthread.dylib 0x00007fff6d3b2b68 start_wqthread + 0
Thread 1 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x0000000000000000 rcx: 0x0000000000000000 rdx: 0x000070000232f760
rdi: 0x0000000000000000 rsi: 0x00007face6d06f04 rbp: 0x000070000232f7a0 rsp: 0x000070000232f7a0
r8: 0x0000000000000058 r9: 0x00000000a5baadb8 r10: 0x00000000a5baadb9 r11: 0x00007fff33278cba
r12: 0x00007facc6c04310 r13: 0x00007face6d24f10 r14: 0x00007facc6c04b20 r15: 0x0000000000000000
rip: 0x00007fff6d3ec8e0 rfl: 0x0000000000010246 cr2: 0x0000000000000000
Logical CPU: 2
Error Code: 0x00000004 (no mapping for user data read)
Trap Number: 14

The crash report of codesign tool shows SIGSEGV

Please post the full crash report. Use the text attachment feature (the paperclip icon) to avoid clogging up the timeline.

Share and Enjoy

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

Here is the full crash report:


Here is the full crash report

Thanks. That leads to a known bug (r. 40837360) where the code signing infrastructure is crashing due to timestamp server problem. We think we understand the issue but it’s not fixed in any public or beta release.

Re-reading your first post it suggests that the problem doesn’t happen all the time. That is, you’ve seen a few failures but you can’t reproduce the problem every time. Is that true?

Share and Enjoy

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

Yes, the issue is intermittent and doesn't happen all the time.

Is there any ETA on the release of fix?

Is there any ETA on the release of fix?

I don’t have any info to share on that.

I’m curious as to whether this is a network problem or a problem that’s local to the Mac doing the signing. You could investigate that with packet trace:

  1. Set up tcpdump on the signing Mac to record all traffic to the timestamp service.

  2. Leave it running.

  3. When you notice this failure, stop tcpdump and look in the packet trace for signs of a networking problem.

Share and Enjoy

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

codesign failing with with 139 exit code
 
 
Q