blueboxd / chromium-legacy

Latest Chromium (≒Chrome Canary/Stable) for Mac OS X 10.7+
BSD 3-Clause "New" or "Revised" License
295 stars 17 forks source link

[CRASH] Browser crash on Hyatt sign in page #224

Open Wowfunhappy opened 4 months ago

Wowfunhappy commented 4 months ago

Upon going to https://www.hyatt.com/en-US/member/sign-in, Chromium Legacy 124.0.6367.207.1 will crash.

Desktop (please complete the following information):

A backtrace is attached.

_Chromium_2024-05-19-191918_Jonathans-Mac-Pro.crash.txt

A couple notes about the backtrace:

• It seems to implicate WebBluetooth, which AFAIK has never worked in Chromium Legacy anyway. • It mentions a function called OnPropertyListFileChangedOnFileThread, which I believe is here. • It says the problem is doesNotRecognizeSelector, which is usually easy to polyfill via Objective-C swizzling. However, in this case, I can't tell what selector it doesn't recognize, it seems to be all C++ code as opposed to Objective-C. (@krackers, can you tell what's happening here?)

Wowfunhappy commented 4 months ago

Oh, this appears in the system console right before the crash:

5/19/24 7:30:52.166 PM _Chromium[66294]: +[NSDictionary dictionaryWithContentsOfURL:error:]: unrecognized selector sent to class 0x7fff7c5c3b60

Okay, so the selector is [NSDictionary dictionaryWithContentsOfURL:error:], which appears to be exactly the same as the older method [NSDictionary dictionaryWithContentsOfURL:]. So that's stupid...

Wowfunhappy commented 4 months ago

Yep, that worked!

#import "ZKSwizzle.h"

@interface myNSDictionary : NSDictionary
@end

@implementation myNSDictionary

+ (NSDictionary *)dictionaryWithContentsOfURL:(NSURL *)url error:(NSError *)error {
    return [NSDictionary dictionaryWithContentsOfURL: url];
}

@end

@implementation NSObject (main)

+ (void)load {
    ZKSwizzle(myNSDictionary, NSDictionary);
}

@end
Wowfunhappy commented 4 months ago

Okay, this is now fixed if you use https://github.com/blueboxd/chromium-legacy/discussions/25. (And now I can book my hotel reservation!)

In terms of fixing in Chromium Legacy... while I'm sure there's a way to alter this in the original source, I would encourage/suggest making some type of compatibility library for functions like this, since I imagine this will come up again and it's an easy way to minimize divergence from upstream.

RJVB commented 4 months ago

Probably a bit tricky for ObjC methods (aka selectors) which are looked up by the runtime, if you have to add them conditionally on the OS version?

EDIT: ahem, what's the download location for the prefpane again? :-/

Wowfunhappy commented 4 months ago

Notably, it looks like Bluebox tried to avoid using [NSDictionary dictionaryWithContentsOfURL:error:] already:

https://github.com/blueboxd/chromium-legacy/commit/5bd5b207d8109b44b191c4ffa3b90f7420e4e320

But he must have missed one... unless this commit didn't make it into the latest release? I still think using some sort of compatibility library is better long-term.

Probably a bit tricky for ObjC methods (aka selectors) which are looked up by the runtime, if you have to add them conditionally on the OS version?

Well, you don't have to do it conditionally, since the old method still works. (Indeed, the commit linked above applies the change to all OS versions.) However, I think it should also be pretty simple to only perform the swizzle if (! __builtin_available(macOS 10.13, *)).