I'm trying to run my application as root with Xcode on macOS, but I keep getting this bizarre error..
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
It's literally just a hello world. All I've added was a printf to the default Obj-C application, tried running it as root, aaaand it ends up on a ud2
instruction somehow. I've tried running Xcode with sudo
, editing the scheme, the combination of the two, and nothing works. It seems like just the thought of root shudders causes Xcode to insert some undefined instruction and crash.
edit: I'm on macOS Catalina 10.15.3 and Xcode 11.4, which I just downloaded yesterday, and this is the code I'm trying to run:
#import <Cocoa/Cocoa.h>
int main(int argc, const char * argv[]) {
printf("Hello world\n");
@autoreleasepool {
// Setup code that might create autoreleased objects goes here.
}
return NSApplicationMain(argc, argv);
}
'My code' doesn't actually do anything. Removing the printf still causes the ud2
instruction crash, so the actual boilerplate developed by Apple doesn't work when run as root..