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

Program crash caused by [initWithUUIDBytes] on macOS intel chip #671

Open
GenkiChiang opened this issue Nov 18, 2024 · 3 comments
Open

Program crash caused by [initWithUUIDBytes] on macOS intel chip #671

GenkiChiang opened this issue Nov 18, 2024 · 3 comments
Labels
A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates bug Something isn't working

Comments

@GenkiChiang
Copy link

I used the data_store_identifier function of wry on the macOS intel chip notebook to pass in the UUID error, and the error message showed that the error was thrown by objc2-foundation. I looked at this lib, and it was probably thrown by this line of code.

Since I use it on macOS with M chip, the program is running normally. intel and M chip macos version, installation dependence, software are the same.
Os:macOS 15.1 (24B83) 2.2 GHz 6core Intel Core i7

throw file:
https://github.com/madsmtm/objc2/blob/master/framework-crates/objc2-foundation/src/uuid.rs

throw message:
thread 'main' panicked at /Users/genki/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc2-foundation-0.2.2/src/uuid.rs:31:1: invalid message send to -[__NSConcreteUUID initWithUUIDBytes:]: expected argument at index 0 to have type code '*', but found '[16C]'

I don't think you should switch UUID by chip architecture
macos 10.8+This interface has not been changed
https://developer.apple.com/documentation/foundation/nsuuid/1417039-initwithuuidbytes

  • (instancetype)initWithUUIDBytes:(const unsigned char *)bytes;
    `
    #[repr(transparent)]
    struct UuidBytes([u8; 16]);

unsafe impl RefEncode for UuidBytes {
// Encoding depends on Foundation version, we hack it for now.
const ENCODING_REF: Encoding = if cfg!(target_arch = "aarch64") {
Encoding::String
} else {
Encoding::Array(16, &u8::ENCODING)
};
}

`

some img
uuid error

@madsmtm madsmtm added this to the objc2 v0.6 / frameworks v0.3 milestone Nov 18, 2024
@madsmtm madsmtm added bug Something isn't working A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates labels Nov 18, 2024
@madsmtm
Copy link
Owner

madsmtm commented Nov 18, 2024

The issue is that while the signature of the function didn't ever change, the internal encoding did, and that's what I've been working around here :/. But you're completely right that the fix is bad, I'll make sure to fix it properly in the next release.

In the meantime, you can do:

[profile.dev.package.objc2]
debug-assertions = false

@GenkiChiang
Copy link
Author

GenkiChiang commented Nov 19, 2024

Thank you very much for your help and reply. Since I have only been in touch with rust for more than a week, I can only find where and why the error was reported. To run forked obj2 locally on macos, GNUstep cannot be installed and it is impossible to verify whether the code can be repaired. I'm sorry I'm not able to provide more repair help.

@madsmtm
Copy link
Owner

madsmtm commented Nov 19, 2024

Don't worry, I know what the issue is. The fix I provided was for you to put in your top-level Cargo.toml. Does that make sense? ;)

Also, you shouldn't need GNUStep on macOS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants