Simplest programs ever fail to launch (killed by Terminal) after compiling with clang. Probably a codesigning pb

Hello everyone,

My Mac is Intell-powered macOS 15.7.7 (24G720)

$ clang --version Apple clang version 17.0.0 (clang-1700.0.13.5) Target: x86_64-apple-darwin24.6.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

I am a long-lasting developper on MacOS.

For a few days, and probably since I have upgraded to MacOS Sequoia, all my C (or C++, etc) programs, even the simplest ever, fail to launch, once compiled with Apple's command line tools :

$ clang simplest_ever_c_program.c
$ ./a.out
Killed: 9
  • The program is killed by MacOS before it launches.
  • This occurs no matter with terminal I use (Zsh, bash, sh...).
  • Removing / reinstalling command line tools did not fix the issue.
  • There is no information printed in the Console.

For some reason while investigating, I have come at some point to suspect a codesigning issue.

**Indeed, signing the code after compilation seems to fix the problem : **

$ clang simplest_ever_c_program.c
$ codesign -s - a.out
Hello World ! Gratz : this progam could be run from the Terminal !

My questions :

  • Why does MacOS suddenly started to kill my own executables compiled with clang ?
  • Would you know how to fix the issue ? (may be an obscure new setting in MacOS preferences ?)

Thanks much for your attention and in advance, Nicolas

Hmmm, that’s weird. On Apple silicon there’s a standard explanation for problems like this. Apple silicon programs must always be code signed. To support this sort of workflow the linker defaults to signing programs, something you can explicitly opt in to and out of via command-line options.

However, you’re on Intel and Intel Macs supports code that’s completely unsigned.

When your program crashes it should generate a crash report. Please post an example of that. See Posting a Crash Report for advice on how to do that.

Share and Enjoy

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

Thank you Eskimo for your answer.

--> there is no crash report generated (only a "killed" message)

--> the Console does not report anything.

However, when launching into the debuggr lldb, some info appear in the Console :

Issued commands :

$ gcc simplest_ever_c_program.c -o simplest_ever_c_program
$ lldb simplest_ever_c_program 
(lldb) target create "simplest_ever_c_program"
Current executable set to '<...>/simplest_ever_c_program' (x86_64).
(lldb) run
Process 83292 launched: '<...>/simplest_ever_c_program' (x86_64)
Process 83292 exited with status = 9 (0x00000009) Terminated due to signal 9
(lldb) run
error: process exited with status -1 (no such process)

(note that first launch in lldb reports a crash with signal 9, while next launch fail to start with "no such process")

At first launch within lldb, the Console finally reports some informations.

Console reports :

par défaut	12:56:32.644706+0200	kernel	Allowing set_exception_ports from [debugserver] on [simplest_ever_c_program] for entitled process/debugger
par défaut	12:56:32.864851+0200	tccd	AUTHREQ_ATTRIBUTION: msgID=249.51, attribution={accessing={TCCDProcess: identifier=<ID of InvalidCode>, pid=83292, auid=501, euid=501, binary_path=/Users/<...>/simplest_ever_c_program}, requesting={TCCDProcess: identifier=com.apple.syspolicyd, pid=249, auid=0, euid=0, binary_path=/usr/libexec/syspolicyd}, },
erreur	12:56:32.866658+0200	tccd	IDENTITY_ATTRIBUTION: Failed to copy signing info for 83292, responsible for /Users/<...>/simplest_ever_c_program: #-67062: Error Domain=NSOSStatusErrorDomain Code=-67062 "(null)"
par défaut	12:56:32.867350+0200	tccd	AUTHREQ_SUBJECT: msgID=249.51, subject=/Users/<...>/simplest_ever_c_program,
par défaut	12:56:32.867966+0200	tccd	-[TCCDAccessIdentity staticCode]: static code for: identifier /Users/<...>/simplest_ever_c_program, type: 1: 0x7fe57c545650 at /Users/<...>/simplest_ever_c_program

FInally : well, dunno why at all, I discovered that using the option -fsanitize=undefined,address seems to fix the issue :

$  clang -fsanitize=undefined,address simplest_ever_c_program.c
$ ./a.out
Hello World ! Gratz : this progam could be run from the Terminal !

Well... May be I should report again this problem in the Developper forum (... concerned with the Apple command line tools) ?

Best- Nicolas

The system won’t pop up the crash report alert but it will still generate a crash report. In Console, on the left, select the Crash Reports item.

I discovered that using the option -fsanitize=undefined,address seems to fix the issue

Well, that’s weird. What exactly is in simplest_ever_c_program.c?

If you build the program in the normal way, what does this report:

% codesign -d -vvv a.out

And then what happens if you do this:

% cp a.out a2.out
% ./a2.out

Share and Enjoy

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

Hello again !

Sorry, but I cannot find any "crash report" in the MacOS Console.

On the left, I have no crash report item (Rapports d'échec in French). I have a "Diagnostic report" (Rapports de diagnostic in French), but there is nothing in it for my executable.

Conversely, I now can find in the Console a "taskgated" entry :

0	déboguer	15:18:51.953388+0200	taskgated	open(/Users/<...>/simplest_ever_c_program,0x0,0x1b6) = 3

(subsystem : com.apple.securityd ; category : unixio ; threadid : 0x25a16a ; PID : 1001)


Well, that’s weird. What exactly is in simplest_ever_c_program.c?
#include <stdio.h>
int main() {
    printf("Hello World ! Gratz : this progam could be run from the Terminal !\n");
    return 0;   
}

(simple, indeed :))


If you build the program in the normal way, what does this report: codesign -d -vvv a.out
$ clang simplest_ever_c_program.c 
$ codesign -d -vvv a.out
a.out: code object is not signed at all

And then what happens if you do this: % cp a.out a2.out % ./a2.out [/quote]
$ clang simplest_ever_c_program.c
$ cp a.out a2.out
$ ./a2.out 
zsh: killed     ./a2.out

thanks again Nicolas

Simplest programs ever fail to launch (killed by Terminal) after compiling with clang. Probably a codesigning pb
 
 
Q