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

PlayKeychain crashes during Minecraft startup #149

Open
VisualEhrmanntraut opened this issue Jun 9, 2024 · 8 comments
Open

PlayKeychain crashes during Minecraft startup #149

VisualEhrmanntraut opened this issue Jun 9, 2024 · 8 comments

Comments

@VisualEhrmanntraut
Copy link

PlayCover 3.0.0 nightly 768
Minecraft 1.19.40. Similar behaviour with 1.17.x, 1.18.x. 1.14.x doesn't crash

Process 90106 stopped
* thread #1, name = 'MINECRAFT MAIN THREAD', queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x10b5b15d0)
    frame #0: 0x000000010b5b15d0 PlayTools`static PlayTools.PlayKeychain.add(_: __C.NSDictionary, result: Swift.Optional<Swift.UnsafeMutablePointer<Swift.Optional<Swift.Unmanaged<Swift.AnyObject>>>>) -> Swift.Int32 + 1988
PlayTools`static PlayTools.PlayKeychain.add(_: __C.NSDictionary, result: Swift.Optional<Swift.UnsafeMutablePointer<Swift.Optional<Swift.Unmanaged<Swift.AnyObject>>>>) -> Swift.Int32:
->  0x10b5b15d0 <+1988>: brk    #0x1
    0x10b5b15d4 <+1992>: brk    #0x1

PlayTools`@objc static PlayTools.PlayKeychain.add(_: __C.NSDictionary, result: Swift.Optional<Swift.UnsafeMutablePointer<Swift.Optional<Swift.Unmanaged<Swift.AnyObject>>>>) -> Swift.Int32:
    0x10b5b15d8 <+0>:    adrp   x4, -1
    0x10b5b15dc <+4>:    add    x4, x4, #0xe0c            ; static PlayTools.PlayKeychain.add(_: __C.NSDictionary, result: Swift.Optional<Swift.UnsafeMutablePointer<Swift.Optional<Swift.Unmanaged<Swift.AnyObject>>>>) -> Swift.Int32
Target 0: (minecraftpe) stopped.
(lldb) bt
* thread #1, name = 'MINECRAFT MAIN THREAD', queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x10b5b15d0)
  * frame #0: 0x000000010b5b15d0 PlayTools`static PlayTools.PlayKeychain.add(_: __C.NSDictionary, result: Swift.Optional<Swift.UnsafeMutablePointer<Swift.Optional<Swift.Unmanaged<Swift.AnyObject>>>>) -> Swift.Int32 + 1988
    frame #1: 0x000000010b5b37f0 PlayTools`merged @objc static PlayTools.PlayKeychain.add(_: __C.NSDictionary, result: Swift.Optional<Swift.UnsafeMutablePointer<Swift.Optional<Swift.Unmanaged<Swift.AnyObject>>>>) -> Swift.Int32 + 68
    frame #2: 0x000000010b58077c PlayTools`pt_SecItemAdd + 96
    frame #3: 0x0000000102737cd8 minecraftpe`___lldb_unnamed_symbol236358 + 396
    frame #4: 0x00000001027380d4 minecraftpe`___lldb_unnamed_symbol236361 + 112
    frame #5: 0x0000000102738374 minecraftpe`___lldb_unnamed_symbol236363 + 284
    frame #6: 0x00000001025464ec minecraftpe`___lldb_unnamed_symbol231387 + 368
    frame #7: 0x0000000102546314 minecraftpe`___lldb_unnamed_symbol231386 + 140
    frame #8: 0x0000000100312e68 minecraftpe`___lldb_unnamed_symbol54249 + 152
    frame #9: 0x0000000100312c2c minecraftpe`___lldb_unnamed_symbol54248 + 332
    frame #10: 0x000000010031859c minecraftpe`___lldb_unnamed_symbol54427 + 1144
    frame #11: 0x0000000100317cb0 minecraftpe`___lldb_unnamed_symbol54425 + 1064
    frame #12: 0x00000001000fe0e0 minecraftpe`___lldb_unnamed_symbol42821 + 1472
    frame #13: 0x000000010019a094 minecraftpe`___lldb_unnamed_symbol44914 + 80
    frame #14: 0x0000000100110a80 minecraftpe`___lldb_unnamed_symbol42880 + 188
    frame #15: 0x000000010011ef54 minecraftpe`___lldb_unnamed_symbol42959 + 8772
    frame #16: 0x000000010011fd28 minecraftpe`___lldb_unnamed_symbol42960 + 24
    frame #17: 0x0000000103a5ae70 minecraftpe`___lldb_unnamed_symbol299452 + 248
    frame #18: 0x00000001904f2804 QuartzCore`CA::Display::DisplayLinkItem::dispatch_(CA::SignPost::Interval<(CA::SignPost::CAEventCode)835322056>&) + 48
    frame #19: 0x0000000190477550 QuartzCore`CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 868
    frame #20: 0x000000019047716c QuartzCore`display_timer_callback(__CFMachPort*, void*, long, void*) + 348
    frame #21: 0x0000000188259fc4 CoreFoundation`__CFMachPortPerform + 296
    frame #22: 0x000000018822aa6c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 60
    frame #23: 0x000000018822a98c CoreFoundation`__CFRunLoopDoSource1 + 524
    frame #24: 0x0000000188229350 CoreFoundation`__CFRunLoopRun + 2244
    frame #25: 0x0000000188228434 CoreFoundation`CFRunLoopRunSpecific + 608
    frame #26: 0x00000001929cc19c HIToolbox`RunCurrentEventLoopInMode + 292
    frame #27: 0x00000001929cbfd8 HIToolbox`ReceiveNextEventCommon + 648
    frame #28: 0x00000001929cbd30 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 76
    frame #29: 0x000000018ba87d68 AppKit`_DPSNextEvent + 660
    frame #30: 0x000000018c27d808 AppKit`-[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 700
    frame #31: 0x000000018ba7b09c AppKit`-[NSApplication run] + 476
    frame #32: 0x000000018ba522e0 AppKit`NSApplicationMain + 880
    frame #33: 0x000000018bca5a30 AppKit`_NSApplicationMainWithInfoDictionary + 24
    frame #34: 0x00000001a14f2f40 UIKitMacHelper`UINSApplicationMain + 972
    frame #35: 0x00000001b767f570 UIKitCore`UIApplicationMain + 148
    frame #36: 0x0000000103a55078 minecraftpe`___lldb_unnamed_symbol299355 + 84
    frame #37: 0x0000000187dc20e0 dyld`start + 2360
image

dies here

kSecAttrKeyClass: attributes["kcls"] as! CFString // swiftlint:disable:this force_cast
due to no kSecAttrKeyClass in the dictionary

@Ryu-ga
Copy link
Contributor

Ryu-ga commented Jun 10, 2024

There is a nil-unwrapping problem in PlayTools, as mentioned. Additionally, there is no implementation of PersistentRef in PlayChain. A fix for these issues might be included later in this pull request.

@VisualEhrmanntraut
Copy link
Author

Why was this closed? It's still happening.
PlayCover Version 3.0.0 (795)
image

@Depal1 Depal1 reopened this Jul 6, 2024
@Depal1
Copy link
Member

Depal1 commented Jul 6, 2024

I can confirm that this issue persists in PlayTools 3.0.0.

@Ryu-ga
Copy link
Contributor

Ryu-ga commented Jul 13, 2024

Screenshot 2024-07-13 at 10 31 15
It seems to work well with this patch: Commit a6646cc.

There is need to find default keychain flags on primary keys.

@dynxssy
Copy link

dynxssy commented Jul 15, 2024

Hey Ryu-ga, this is amazing, could you please explain how you got it working?

@Ryu-ga
Copy link
Contributor

Ryu-ga commented Jul 18, 2024

Hey Ryu-ga, this is amazing, could you please explain how you got it working?

We believe that the SecItem methods should work with the necessary primary keys, but Minecraft uses deficient keys and it works well in the real iOS platform and MacOS. The SecItem method in PlayChain was not working with that, so I added a default key as a replacement.

@VisualEhrmanntraut
Copy link
Author

VisualEhrmanntraut commented Jul 18, 2024

The problem with this specific invocation is the lack of key class specification. Whether this is wrong or not is unclear in Apple's documentation, as it doesn't mention whether you have to specify it or not. If it's not wrong, then kSecClassKey is the most likely default value. Otherwise, I'm not sure, but it may error and Minecraft go to a fallback.

@VisualEhrmanntraut VisualEhrmanntraut changed the title SecItemAdd incompatibility with Minecraft PlayKeychain crashes during Minecraft startup Jul 18, 2024
@seidnerj
Copy link

seidnerj commented Sep 3, 2024

Hey Ryu-ga, this is amazing, could you please explain how you got it working?

We believe that the SecItem methods should work with the necessary primary keys, but Minecraft uses deficient keys and it works well in the real iOS platform and MacOS. The SecItem method in PlayChain was not working with that, so I added a default key as a replacement.

Did you open a PR for this commit? thx

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

No branches or pull requests

6 participants