Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS 12 Monterey #923

Closed
dominiklohmann opened this issue Jun 8, 2021 · 241 comments
Closed

macOS 12 Monterey #923

dominiklohmann opened this issue Jun 8, 2021 · 241 comments

Comments

@dominiklohmann
Copy link
Collaborator

This is the collective yearly thread for macOS betas. Please use this to discuss instead of opening new issues.

I will try to keep this updated just like every year.

2021-06-07 Developer Beta 1 (21A5248p)

Dock.app is available at Dock.app.zip.

Issue Note
build from source fails
Click to expand build log
❯ make
rm -rf ./bin
xcrun clang ./src/osax/loader.m -shared -O2 -mmacosx-version-min=10.13 -o ./src/osax/loader -framework Foundation
xcrun clang ./src/osax/payload.m -shared -fPIC -O2 -mmacosx-version-min=10.13 -o ./src/osax/payload -framework Foundation -framework Carbon
./src/osax/payload.m:37:8: error: unknown type name 'CGError'; did you mean 'NSError'?
extern CGError CGSGetConnectionPSN(int cid, ProcessSerialNumber *psn);
       ^~~~~~~
       NSError
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserScriptTask.h:8:88: note: 'NSError' declared here
@class NSAppleEventDescriptor, NSArray<ObjectType>, NSDictionary<KeyType, ObjectType>, NSError, NSFileHandle, NSString, NSURL, NSXPCConnection;
                                                                                       ^
./src/osax/payload.m:37:8: error: interface type 'NSError' cannot be returned by value; did you forget * in 'NSError'?
extern CGError CGSGetConnectionPSN(int cid, ProcessSerialNumber *psn);
       ^
              *
./src/osax/payload.m:38:8: error: unknown type name 'CGError'; did you mean 'NSError'?
extern CGError CGSSetWindowAlpha(int cid, uint32_t wid, float alpha);
       ^~~~~~~
       NSError
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserScriptTask.h:8:88: note: 'NSError' declared here
@class NSAppleEventDescriptor, NSArray<ObjectType>, NSDictionary<KeyType, ObjectType>, NSError, NSFileHandle, NSString, NSURL, NSXPCConnection;
                                                                                       ^
./src/osax/payload.m:38:8: error: interface type 'NSError' cannot be returned by value; did you forget * in 'NSError'?
extern CGError CGSSetWindowAlpha(int cid, uint32_t wid, float alpha);
       ^
              *
./src/osax/payload.m:39:8: error: unknown type name 'CGError'; did you mean 'NSError'?
extern CGError CGSSetWindowListAlpha(int cid, const uint32_t *window_list, int window_count, float alpha, float duration);
       ^~~~~~~
       NSError
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserScriptTask.h:8:88: note: 'NSError' declared here
@class NSAppleEventDescriptor, NSArray<ObjectType>, NSDictionary<KeyType, ObjectType>, NSError, NSFileHandle, NSString, NSURL, NSXPCConnection;
                                                                                       ^
./src/osax/payload.m:39:8: error: interface type 'NSError' cannot be returned by value; did you forget * in 'NSError'?
extern CGError CGSSetWindowListAlpha(int cid, const uint32_t *window_list, int window_count, float alpha, float duration);
       ^
              *
./src/osax/payload.m:40:8: error: unknown type name 'CGError'; did you mean 'NSError'?
extern CGError CGSSetWindowLevel(int cid, uint32_t wid, int level);
       ^~~~~~~
       NSError
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserScriptTask.h:8:88: note: 'NSError' declared here
@class NSAppleEventDescriptor, NSArray<ObjectType>, NSDictionary<KeyType, ObjectType>, NSError, NSFileHandle, NSString, NSURL, NSXPCConnection;
                                                                                       ^
./src/osax/payload.m:40:8: error: interface type 'NSError' cannot be returned by value; did you forget * in 'NSError'?
extern CGError CGSSetWindowLevel(int cid, uint32_t wid, int level);
       ^
              *
./src/osax/payload.m:42:8: error: unknown type name 'CGError'; did you mean 'NSError'?
extern CGError CGSReassociateWindowsSpacesByGeometry(int cid, CFArrayRef window_list);
       ^~~~~~~
       NSError
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserScriptTask.h:8:88: note: 'NSError' declared here
@class NSAppleEventDescriptor, NSArray<ObjectType>, NSDictionary<KeyType, ObjectType>, NSError, NSFileHandle, NSString, NSURL, NSXPCConnection;
                                                                                       ^
./src/osax/payload.m:42:8: error: interface type 'NSError' cannot be returned by value; did you forget * in 'NSError'?
extern CGError CGSReassociateWindowsSpacesByGeometry(int cid, CFArrayRef window_list);
       ^
              *
./src/osax/payload.m:43:8: error: unknown type name 'CGError'; did you mean 'NSError'?
extern CGError CGSGetWindowOwner(int cid, uint32_t wid, int *window_cid);
       ^~~~~~~
       NSError
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserScriptTask.h:8:88: note: 'NSError' declared here
@class NSAppleEventDescriptor, NSArray<ObjectType>, NSDictionary<KeyType, ObjectType>, NSError, NSFileHandle, NSString, NSURL, NSXPCConnection;
                                                                                       ^
./src/osax/payload.m:43:8: error: interface type 'NSError' cannot be returned by value; did you forget * in 'NSError'?
extern CGError CGSGetWindowOwner(int cid, uint32_t wid, int *window_cid);
       ^
              *
./src/osax/payload.m:44:8: error: unknown type name 'CGError'; did you mean 'NSError'?
extern CGError CGSInvalidateWindowShadow(int cid, CGWindowID wid);
       ^~~~~~~
       NSError
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserScriptTask.h:8:88: note: 'NSError' declared here
@class NSAppleEventDescriptor, NSArray<ObjectType>, NSDictionary<KeyType, ObjectType>, NSError, NSFileHandle, NSString, NSURL, NSXPCConnection;
                                                                                       ^
./src/osax/payload.m:44:51: error: unknown type name 'CGWindowID'
extern CGError CGSInvalidateWindowShadow(int cid, CGWindowID wid);
                                                  ^
./src/osax/payload.m:44:8: error: interface type 'NSError' cannot be returned by value; did you forget * in 'NSError'?
extern CGError CGSInvalidateWindowShadow(int cid, CGWindowID wid);
       ^
              *
./src/osax/payload.m:45:8: error: unknown type name 'CGError'; did you mean 'NSError'?
extern CGError CGSSetWindowTags(int cid, uint32_t wid, const int tags[2], size_t maxTagSize);
       ^~~~~~~
       NSError
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserScriptTask.h:8:88: note: 'NSError' declared here
@class NSAppleEventDescriptor, NSArray<ObjectType>, NSDictionary<KeyType, ObjectType>, NSError, NSFileHandle, NSString, NSURL, NSXPCConnection;
                                                                                       ^
./src/osax/payload.m:45:8: error: interface type 'NSError' cannot be returned by value; did you forget * in 'NSError'?
extern CGError CGSSetWindowTags(int cid, uint32_t wid, const int tags[2], size_t maxTagSize);
       ^
              *
./src/osax/payload.m:46:8: error: unknown type name 'CGError'; did you mean 'NSError'?
extern CGError CGSClearWindowTags(int cid, uint32_t wid, const int tags[2], size_t maxTagSize);
       ^~~~~~~
       NSError
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserScriptTask.h:8:88: note: 'NSError' declared here
@class NSAppleEventDescriptor, NSArray<ObjectType>, NSDictionary<KeyType, ObjectType>, NSError, NSFileHandle, NSString, NSURL, NSXPCConnection;
                                                                                       ^
./src/osax/payload.m:46:8: error: interface type 'NSError' cannot be returned by value; did you forget * in 'NSError'?
extern CGError CGSClearWindowTags(int cid, uint32_t wid, const int tags[2], size_t maxTagSize);
       ^
              *
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [src/osax/sa_loader.c] Error 1
constant crashes See #920 for details.
@shaunsingh
Copy link

Appreciate it, thank you

how would I know if an application is frameless

If you don't know about it, then you probably aren't using it.

@beeaniebee
Copy link

If you don't know about it, then you probably aren't using it.

then I doubt it. I was using firefox nightly by the way since at this point any bit of info would probably help

@beeaniebee
Copy link

fixing the source code compiling would be the first step would it not? I'll see what I can find out

@beeaniebee
Copy link

manually adding #include <CoreGraphics/CoreGraphics.h> to the /src/osax/payload.m file gets source code to compile

@beeaniebee
Copy link

this is a temp fix I assume, but its possible it could work just fine

@beeaniebee
Copy link

still segfaults though

@beeaniebee
Copy link

* thread #4, stop reason = EXC_BAD_ACCESS (code=1, address=0x18)
    frame #0: 0x00007ff8125fa09d libobjc.A.dylib`objc_msgSend + 29
libobjc.A.dylib`objc_msgSend:
->  0x7ff8125fa09d <+29>: andl   0x18(%r10), %r11d
    0x7ff8125fa0a1 <+33>: shlq   $0x4, %r11
    0x7ff8125fa0a5 <+37>: addq   0x10(%r10), %r11
    0x7ff8125fa0a9 <+41>: cmpq   (%r11), %rsi
Target 0: (yabai) stopped.
(lldb) bt
* thread #4, stop reason = EXC_BAD_ACCESS (code=1, address=0x18)
  * frame #0: 0x00007ff8125fa09d libobjc.A.dylib`objc_msgSend + 29
    frame #1: 0x00007ff815205f01 AppKit`-[NSRunningApplication activationPolicy] + 33
    frame #2: 0x000000010002a573 yabai`EVENT_HANDLER_APPLICATION_LAUNCHED + 131
    frame #3: 0x00000001000078c4 yabai`event_loop_run + 100
    frame #4: 0x00007ff81275e5b8 libsystem_pthread.dylib`_pthread_start + 125
    frame #5: 0x00007ff81275a0d3 libsystem_pthread.dylib`thread_start + 15

heres a quick lldb backtrace, although I'm totally useless after this point lol

@shaunsingh
Copy link

https://github.com/shaunsingh/yabai/blob/0d2e49eebe7c1d6848e9ab5b32687a372e21cc6f/src/osax/payload.m#L193

Do lines referring to macOS 11 need to be updated to reference macOS 12 as well?

@beeaniebee
Copy link

that still segfaults. good guess tho lol

@beeaniebee
Copy link

I'm trying to get lldb to debug with the source code but as I said I'm completely useless at debugging binaries. Anyone have a tip to get source code rather than assembler code in the lldb output?

@sean-hale-dev
Copy link

If you compile with -g set it should keep the file and line number of the error

@beeaniebee
Copy link

it already is though.. that's what's so confusing to me. It's compiled with the right flags as far as i know, with -g and -O0, and lldb says that the .dSYM file is there, but doesn't show source code in the debugging output

@sean-hale-dev
Copy link

It looks like something is causing an apple service to segfault that yabai is calling, which is why compiling with -g isn't changing anything. The segfault is caused in lib_objc not in the yabai codebase

@beeaniebee
Copy link

Hey that's smart! I bet that's it. Does that then mean it's possible to trace the call back to the line of yabai code that caused the segfault?

@vespakoen
Copy link

Does xorpse's fork work?

brew install --HEAD xorpse/formulae/yabai

It was made to support the M1 Apple computers, but seems to have updated references for Monterey, not sure if it runs on x86_64 though...

@diegoquiroz
Copy link

Just tried and no, xorpse's fork doesn't support MacOS 12 for x86

@TheNoim
Copy link

TheNoim commented Jun 20, 2021

We need someone who knows how to update the patterns here https://github.com/shaunsingh/yabai/blob/0d2e49eebe7c1d6848e9ab5b32687a372e21cc6f/src/osax/x86_64/payload.m#L99 and the offsets.

Maybe @koekeishiya in some point of the future could write down how to find them. If more people would know how to find them, we would maybe get faster updates for yabai. Especially if @koekeishiya isn't always on the newest version.

@xorpse
Copy link

xorpse commented Jun 23, 2021

For x86-64, in init_instances of src/osax/payload.m, altering the way the pointers are computed to use the following might work:

if (os_version.majorVersion == 12) {
        uint64_t baseaddr = image_slide();

        if (0x100000000ULL != static_base_address()) {
            NSLog(@"[yabai-sa] payload offsets not compatible with OS version!");
            return;
        }

        // globals
        dock_spaces = [(*(id *)(baseaddr + 0x100434CB8ULL)) retain];
        dp_desktop_picture_manager = [(*(id *)(baseaddr + 0x100434D38ULL)) retain];

        // function pointers
        add_space_fp = baseaddr + 0x10022F760ULL;
        remove_space_fp = baseaddr + 0x1002E718AULL;
        move_space_fp = baseaddr + 0x1002D7D2DULL;
        set_front_window_fp = baseaddr + 0x100051E40ULL;

        NSLog(@"[yabai-sa] payload offsets computed relative to %llx", baseaddr);
} else { // < 12.x...
     // move old code here
}

As @vespakoen pointed out, the arm64 addresses are already in my fork, but from this thread, it looks like there are other issues that need to be addressed to get it to compile. Anyway, I can't test the above, but the addresses should be good at the very least, if someone is able to build on that.

With regards to finding the patterns/addresses going forward, for arm64, after manually finding them all for one version of Dock, I've been able to use diaphora to find them for future versions with relative ease. You can download the databases I've made for 12 beta 1 from here:

@alin23
Copy link

alin23 commented Jun 23, 2021

@xorpse I got yabai to compile and even inject the SA on beta 1. Everything seemed to work fine, even the SA stuff like space focus and PiP.

Until the WindowServer crashed completely.. I kept using it for a while but the WindowServer crashes every 10 minutes and I would need to relogin and reopen the windows everytime.

I suspect this is a bug in the current beta, I don't see how the SA could cause these kind of crashes.

We have to be a bit more patient 😅 things are expected to fail in a beta

@xorpse
Copy link

xorpse commented Jun 23, 2021

@alin23 Nice :)! Yep, I'd imagine if the crashes are to do with the scripting additions, they would happen more or less instantly after one of the actions associated with the pointers we're using in Dock is triggered.

@shaunsingh
Copy link

@xorpse is it possible to allow your fork to build on macOS 12 as well? Currently on my m1 machine it fails with the payload.m issue as well. Someone mentioned adding #include <CoreGraphics/CoreGraphics.h> to the /src/osax/payload.m should do the trick

@xorpse
Copy link

xorpse commented Jun 24, 2021

@shaunsingh I've pushed the addresses/offsets for x86-64 and header addition to my fork, see if it works for you.

@shaunsingh
Copy link

@xorpse It installs now, but gives the following output if I try to start it

~
❯ yabai
fish: Job 1, 'yabai' terminated by signal SIGKILL (Forced quit)

The same thing happens on zsh. I've signed the app and installed it via brew install xorpse/formulae/yabai --HEAD

@xorpse
Copy link

xorpse commented Jun 24, 2021

@shaunsingh You'll have to build it directly from the repository (i.e., clone then run make -f makefile). The brew formula at xorpse/formulae/yabai builds yabai for arm64e rather than x86-64 (you can confirm via file $(which yabai)).

@alin23
Copy link

alin23 commented Jun 24, 2021

In my case, I had to revert the following two commits and keep using frida to make it work on 12 beta 1:

xorpse@3f0f1a6

xorpse@3354518

@shaunsingh
Copy link

@xorpse I have an m1 (aarch64) machine, should I still clone it manually?

@xorpse
Copy link

xorpse commented Jun 24, 2021

@shaunsingh Sorry I totally missed you were trying it on an M1... I don't plan on upgrading to 12 for the time being---so right now, I can't help more than I have already. I'd follow the advice that @alin23 gave and use the Frida injector instead of the bundled one.

@alin23 so the non-Frida injector doesn't work at all on 12? Do you happen to have any logs of the crashes?

@alin23
Copy link

alin23 commented Jun 24, 2021

No logs and no debug info. The process is SIGKILLed instantly. Not even lldb can spawn it.

I suspect the PC register points to some non-executable code somehow, but I haven't looked into the injection code in detail.

@koekeishiya
Copy link
Owner

koekeishiya commented Nov 18, 2021

I have tested that the master branch builds fine for me on macOS Big Sur 11.6.1 (Intel) and macOS Monterey 12.0.1 (Apple Silicon). Both builds work when I send them to my other device, both ways. Make sure your Xcode is up to date. Also what is the output of xcode-select -p

Here is a pre-built version (with debug symbols) of commit (727b112): yabai-v4.0.0.tar.gz

I have verified that it runs on both arm64 (12.0.1) and x86-64 (11.6.1).

Edit: I am using Xcode v13.1 (13A1030d) on both devices (not command line tools) and Apple clang version 13.0.0 (clang-1300.0.29.3).

@storopoli
Copy link

storopoli commented Nov 18, 2021

With yabai from --HEAD, SIP totally disable, codesigned I still get this warning and I cannot install payload:

❯ yabai -v
yabai-v4.0.0
❯ sudo yabai --load-sa

could not set thread state: (os/kern) protection failure
yabai: scripting-addition failed to inject payload into Dock.app!

❯ csrutil status
System Integrity Protection status: disabled.

EDIT: I am on a MacOS M1:

❯ neofetch
                    'c.          storopoli@Duda-M1
                 ,xNMM.          -----------------
               .OMMMMo           OS: macOS 12.0.1 21A559 arm64
               OMMM0,            Host: MacBookAir10,1
     .;loddo:' loolloddol;.      Kernel: 21.1.0
   cKMMMMMMMMMMNWMMMMMMMMMM0:    Uptime: 9 mins
 .KMMMMMMMMMMMMMMMMMMMMMMMWd.    Packages: 284 (brew)
 XMMMMMMMMMMMMMMMMMMMMMMMX.      Shell: zsh 5.8
;MMMMMMMMMMMMMMMMMMMMMMMM:       Resolution: 1440x900
:MMMMMMMMMMMMMMMMMMMMMMMM:       DE: Aqua
.MMMMMMMMMMMMMMMMMMMMMMMMX.      WM: yabai
 kMMMMMMMMMMMMMMMMMMMMMMMMWd.    Terminal: tmux
 .XMMMMMMMMMMMMMMMMMMMMMMMMMMk   CPU: Apple M1
  .XMMMMMMMMMMMMMMMMMMMMMMMMK.   GPU: Apple M1
    kMMMMMMMMMMMMMMMMMMMMMMd     Memory: 1109MiB / 8192MiB
     ;KMMMMMMMWXXWMMMMMMMk.
       .cooc,.    .,coo:.

@koekeishiya
Copy link
Owner

@storopoli You probably have not yet changed the boot-args to allow for non-Apple-signed arm64e binaries.
I have updated the wiki page here

@albert-ying
Copy link

albert-ying commented Nov 18, 2021

Edit: I am using Xcode v13.1 (13A1030d) on both devices (not command line tools) and Apple clang version 13.0.0 (clang-1300.0.29.3).

I have the exact same version of these two things. xcode-select -p gives me /Applications/Xcode.app/Contents/Developer

I tried the prebuilt file you shared (thank you so much). It works well so far. But still wondering why brew doesn't work... and now I cannot do the brew service thing to automate it.

@storopoli
Copy link

storopoli commented Nov 18, 2021

I get the following error on the System recovery Terminal:

nvram boot-args=-arm64e_preview_abi
Error setting variable - 'boot-args': (iokit/common) not permitted.

And the output of csrutil status:

System Integrity Protection status: unkown (Custom Configuration).

Configuration:
    Apple Internal: enabled
    Kext Signing: enabled
    Filesystem Protection: disabled
    Debugging Restrictions: disabled
    DTrace Restrictions: enabled
    NVRAM Protections: disabled
    BaseSystem verification: enabled
    Boot-arg Restrictions: disabled
    Kernel Integrity Protection: disabled
    Authenticated Root Requirement: enabled

@albert-ying
Copy link

@storopoli I got the same error. Run sudo nvram boot-args=-arm64e_preview_abi in a regular terminal and reboot solved my problem.

@bentosquares
Copy link

bentosquares commented Nov 19, 2021

Same issue here. M1 Macbook Pro, Xcode 13.1. I have re-enabled SIP and cleared nvram boot arguments to defaults so that I can go all the way through the process again twice now, but still receive

could not set thread state: (os/kern) protection failure
yabai: scripting-addition failed to inject payload into Dock.app!

when loading the scripting addon.

# yabai -v
yabai-v4.0.0
# csrutil status
System Integrity Protection status: unknown (Custom Configuration).

Configuration:
	Apple Internal: disabled
	Kext Signing: enabled
	Filesystem Protections: disabled
	Debugging Restrictions: disabled
	DTrace Restrictions: enabled
	NVRAM Protections: disabled
	BaseSystem Verification: enabled
	Boot-arg Restrictions: disabled
	Kernel Integrity Protections: disabled
	Authenticated Root Requirement: enabled

This is an unsupported configuration, likely to break in the future and leave your machine in an unknown state.
# nvram -p
ota-updateType	package
boot-args	-arm64e_preview_abi
# xcode-select -p
/Applications/Xcode.app/Contents/Developer

@DennisFeldbusch
Copy link

@evprkr I don't know and I definitely could be wrong, but my intuition screams that your problem (which seems to uniquely effect you) is the result of doing a app != '^(a|b|c)$' manage=off rule.
I honestly wouldn't expect it to go well, and I think it alone can explain your problem.
What I think is happening is like this:

  1. Something on your computer generates (invisible) windows intermittently. (Or you just open a window that you expect yabai to ignore)
  2. The main event loop of yabai dutifully starts to adjust the layout to fit the new window in
  3. The rule processor finishes processing the window added event and determines it is supposed to be a floating window, so it removes it from the layout
  4. The other windows adjust for the removal of that window in the layout (before it was necessarily ever drawn)

I would seriously consider trying an alternative approach to your filtering. Like, for example, using a float or stack layout space default and setting manage=on rules for the apps you do want to layout.
I'm not sure that will work either, but I'm just ... not surprised that the thing you are trying now doesn't. I'd honestly never expect it to (and therefore would never have thought to try it)

I'm also experience these random reshuffling issue and I use the following config

Tomorrow I will test if commenting out the rules will help with the issue

I tested it with the newest master version and with my rules enabled and that solved it for me!!
Thank you very much @koekeishiya !!

@koekeishiya
Copy link
Owner

@storopoli

I get the following error on the System recovery Terminal:

nvram boot-args=-arm64e_preview_abi
Error setting variable - 'boot-args': (iokit/common) not permitted.

You are correct; I see the same behaviour. I have updated the wiki so that it mentions that this command must be run as root after exiting recovery mode and rebooting. Previously it was possible to run the nvram command in recovery mode after SIP had been disabled (possibly can be done in recovery after a reboot between the initial command to disable SIP, but then it might as well be done from a normal user session using sudo).

@bentosquares

Did you reboot after changing the boot-args? I am unable to reproduce a failure in thread_set_state on my end, with seemingly the same config:
Screenshot 2021-11-19 at 09 26 51

@DennisFeldbusch

That's great, hopefully it remains stable for the most part.

@robinsturmeit
Copy link

Thank you so much for the work to get this running for Monterey. It's a shame that window borders don't work anymore, but I'm happy to have my window tiling back!

However, yabai -m space --focus commands still don't seem to work for me, even though they exit with 0 as does sudo yabai --load-sa. Logs don't show anything.

System details:
Screenshot 2021-11-19 at 09 45 44

@storopoli
Copy link

@koekeishiya I am still getting the same error after several reboots:

❯ csrutil status
System Integrity Protection status: unknown (Custom Configuration).

Configuration:
        Apple Internal: disabled
        Kext Signing: enabled
        Filesystem Protections: disabled
        Debugging Restrictions: disabled
        DTrace Restrictions: enabled
        NVRAM Protections: disabled
        BaseSystem Verification: enabled
        Boot-arg Restrictions: disabled
        Kernel Integrity Protections: disabled
        Authenticated Root Requirement: enabled

This is an unsupported configuration, likely to break in the future and leave your machine in an unknown state.
❯ xcode-select -p
/Library/Developer/CommandLineTools
❯ sudo nvram -p | grep boot
boot-volume     EF57347C-0000-AA11-AA11-00306543ECAC:576803DC-8B8D-BE42-9141-4141C7094374:FAFD0CFB-7CCB-49C0-9981-FF31A5E49942
upgrade-boot-volume     EF57347C-0000-AA11-AA11-00306543ECAC:576803DC-8B8D-BE42-9141-4141C7094374:5F9234CF-C7F4-496F-B5F4-646CA2537157
boot-args       -arm64e_preview_abi
❯ yabai -v
yabai-v4.0.0
❯ sudo yabai --load-sa
could not set thread state: (os/kern) protection failure
yabai: scripting-addition failed to inject payload into Dock.app!

@koekeishiya
Copy link
Owner

@robinsturmeit

You can look for logs in Console.app. Select your device on the left, and filter for "Dock" at the right, as shown in the below screenshot. Make sure no previous injection of the scripting-addition has been attempted; run pkill Dock first if it has. Clear the log window first for less noise, then run sudo yabai --load-sa and assuming it returns no error, you should see something like the following:

Screenshot 2021-11-19 at 09 52 49

@koekeishiya
Copy link
Owner

@storopoli Can you post the output of the following:

cat /Library/ScriptingAdditions/yabai.osax/Contents/Info.plist | grep -A 1 CFBundleVersion

file /Library/ScriptingAdditions/yabai.osax/Contents/Resources/payload.bundle/Contents/MacOS/payload

file /Library/ScriptingAdditions/yabai.osax/Contents/MacOS/mach_loader

This is what it should look like:

~ cat /Library/ScriptingAdditions/yabai.osax/Contents/Info.plist | grep -A 1 CFBundleVersion                 9:57
<key>CFBundleVersion</key>
<string>2.0.0</string>
~ file /Library/ScriptingAdditions/yabai.osax/Contents/Resources/payload.bundle/Contents/MacOS/payload       9:57
/Library/ScriptingAdditions/yabai.osax/Contents/Resources/payload.bundle/Contents/MacOS/payload: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64e:Mach-O 64-bit dynamically linked shared library arm64e]
/Library/ScriptingAdditions/yabai.osax/Contents/Resources/payload.bundle/Contents/MacOS/payload (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64
/Library/ScriptingAdditions/yabai.osax/Contents/Resources/payload.bundle/Contents/MacOS/payload (for architecture arm64e):	Mach-O 64-bit dynamically linked shared library arm64e
~ file /Library/ScriptingAdditions/yabai.osax/Contents/MacOS/mach_loader                                     9:57
/Library/ScriptingAdditions/yabai.osax/Contents/MacOS/mach_loader: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
/Library/ScriptingAdditions/yabai.osax/Contents/MacOS/mach_loader (for architecture x86_64):	Mach-O 64-bit executable x86_64
/Library/ScriptingAdditions/yabai.osax/Contents/MacOS/mach_loader (for architecture arm64e):	Mach-O 64-bit executable arm64e

@storopoli
Copy link

Here it is:

❯ cat /Library/ScriptingAdditions/yabai.osax/Contents/Info.plist | grep -A 1 CFBundleVersion
<key>CFBundleVersion</key>
<string>2.0.0</string>
❯ file /Library/ScriptingAdditions/yabai.osax/Contents/Resources/payload.bundle/Contents/MacOS/payload
/Library/ScriptingAdditions/yabai.osax/Contents/Resources/payload.bundle/Contents/MacOS/payload: Mach-O 64-bit dynamically linked shared library arm64
❯ file /Library/ScriptingAdditions/yabai.osax/Contents/MacOS/mach_loader
/Library/ScriptingAdditions/yabai.osax/Contents/MacOS/mach_loader: Mach-O 64-bit executable arm64

@koekeishiya
Copy link
Owner

Well the issue is that for some reason your scripting-addition is not being built as a universal binary. I don't really know why that is. The current master builds a universal binary on both my Intel MacBook running 11.6.1, and my Apple Silicon MacBook running 12.0.1. Note that I am not using brew while testing, so maybe that could somehow cause a difference in compilation, even though it uses the same makefile?? I'm not sure how to debug that issue further.

@storopoli
Copy link

I will try to build from master without brew

@storopoli
Copy link

I cannot build from master:

sudo make install
rm -rf ./bin
clang ./src/osax/loader.m -shared -O2 -mmacosx-version-min=10.13 -o ./src/osax/loader -framework Foundation
clang ./src/osax/payload.m -shared -fPIC -O2 -mmacosx-version-min=10.13 -arch arm64e -o ./src/osax/payload -framework Foundation -framework Carbon
./src/osax/payload.m:29:10: fatal error: 'ptrauth.h' file not found
#include <ptrauth.h>
         ^~~~~~~~~~~
1 error generated.
make: *** [src/osax/loader_bin.c] Error 1

@koekeishiya
Copy link
Owner

koekeishiya commented Nov 19, 2021

I wonder what exactly is causing the command run from the makefile to differ from the one actually at the master branch. Do you have some custom clang version installed that takes precedence over the XCode / command line tools version? This seems likely to me as it appears that a standard header that should be included, is in fact not.

This is the line i expected to see:

clang ./src/osax/payload.m -shared -fPIC -O2 -mmacosx-version-min=10.13 -arch x86_64 -arch arm64e -o ./src/osax/payload -framework Foundation -framework Carbon

Notice how it refuses to build a universal binary containing two images; the x86_64 part is just stripped from your version, which shouldn't happen.

@storopoli
Copy link

Ok, I think I got this. I've installed with brew install yabai --HEAD and them downloaded the prebuilt binary I posted in: #923 (comment) .

Then I did this (a kinda hack):

cd Desktop/archive/bin/
mv yabai /opt/homebrew/Cellar/yabai/HEAD-6bcf544/bin/yabai
override r-xr-xr-x  storopoli/admin for /opt/homebrew/Cellar/yabai/HEAD-6bcf544/bin/yabai? (y/n [n]) y

It seem to be working now.

@koekeishiya
Copy link
Owner

Closing in favour of #1054.

@koekeishiya koekeishiya unpinned this issue Nov 19, 2021
@muvox
Copy link

muvox commented Nov 19, 2021

Ok, I think I got this. I've installed with brew install yabai --HEAD and them downloaded the prebuilt binary I posted in: #923 (comment) .

Then I did this (a kinda hack):

cd Desktop/archive/bin/
mv yabai /opt/homebrew/Cellar/yabai/HEAD-6bcf544/bin/yabai
override r-xr-xr-x  storopoli/admin for /opt/homebrew/Cellar/yabai/HEAD-6bcf544/bin/yabai? (y/n [n]) y

It seem to be working now.

For whatever reason, this worked. I tried brew install head and sudo make install and I'm pretty confident that I followed the instructions to the letter. After I saw this comment, i removed all old installations and did a
brew install koekeishiya/formulae/yabai --HEAD
followed by copying the before mentioned pre-built binary to the correct directory. Install sa and load sa worked like a charm and I can keep working again! Huge thanks to @koekeishiya and @storopoli

@bentosquares
Copy link

@bentosquares

Did you reboot after changing the boot-args? I am unable to reproduce a failure in thread_set_state on my end, with seemingly the same config: Screenshot 2021-11-19 at 09 26 51

I had done, but I see you've tracked down the issue, my results mirror that of @storopoli. The hack of replacing the binary with the pre-compiled copy has also worked for me. Thanks to you both. Good luck in tracking down the issues with the Brew process! And thanks for such a great piece of software.

@Christopher-Hayes
Copy link

Closing in favour of #1054.

I'm running Monterey on Intel, it's hard to follow what solutions in that thread are for Monterey and what issues are for M1.

@koekeishiya
Copy link
Owner

koekeishiya commented Apr 6, 2022

Install the latest version released (v4.0.0) either through brew or grab it from the GitHub releases page.

@Christopher-Hayes
Copy link

@koekeishiya thanks! After upgrading 3.3 -> 4.0, it looks like that fixed the scripting additions notification spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests