8000 fontique: Fix panic on macOS in debug mode. by NoahR02 · Pull Request #335 · linebender/parley · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fontique: Fix panic on macOS in debug mode. #335

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

Merged
merged 4 commits into from
Apr 17, 2025

Conversation

NoahR02
Copy link
Contributor
@NoahR02 NoahR02 commented Apr 12, 2025

This commit fixes a panic on macOS by enabling the "relax-sign-encoding" feature for the "objc2" crate.

Relevant issues in the objc2 crate:
madsmtm/objc2#566
madsmtm/objc2#567

I made sure to use version of objc2 that the current objc2-* variations use, so that we don't duplicate the crate.
Screenshot 2025-04-11 at 8 51 30 PM


Additional Info:

System Info: Mac Mini M4, 16 GB of RAM.

Before the fix, when running the vello-editor or any example:
Screenshot 2025-04-11 at 9 12 02 PM

After the fix:
Screenshot 2025-04-11 at 9 14 29 PM

NoahR02 added 4 commits April 11, 2025 21:18
This commit fixes a panic on macOS by enabling the "relax-sign-encoding" feature for the "objc2" crate.

Relevant issues in the objc2 crate:
madsmtm/objc2#566
madsmtm/objc2#567
See the commit below, for why we need the objc2 crate.
@xorgy
Copy link
Member
xorgy commented Apr 12, 2025

Could you document the issue a bit more? I can't reproduce (vello_editor in main just runs fine for me on an M1 Mac Mini running Sequoia).

@NoahR02
Copy link
Contributor Author
NoahR02 commented Apr 12, 2025

Could you document the issue a bit more? I can't reproduce (vello_editor in main just runs fine for me on an M1 Mac Mini running Sequoia).

From what I understand after reading this issue: madsmtm/objc2#566, Swift tries to use NSInteger instead of NSUInteger for countByEnumeratingWithState_objects_count's return type.

Here is a link to the obj-c docs https://developer.apple.com/documentation/foundation/nsfastenumeration/countbyenumerating(with:objects:count:)?language=objc and the FFI binding function is listed below:
image

The panic is happening because of this line which likely interprets the function's return type as a signed integer:
image

You can ultimately track down this panic to this verification error, which is getting back a LongLong instead of the expected ULongLong.
image

image


I'm not too sure why this error doesn't persist on your side as I'm also running Sequoia 15.4.

Notes:

@NoahR02
Copy link
Contributor Author
NoahR02 commented Apr 12, 2025

One more important piece of information that I just discovered is that this only happens in debug mode, release mode works fine. The objc2 library is most likely not checking the method signature in release mode and that is why it works in the release build.

@jamesthurley
Copy link
jamesthurley commented Apr 12, 2025

FWIW, I just ran into this as well. I started getting the error:

expected return to have type code 'q', but found 'Q'

from objc2 via [fontique](fontique::scan::scan_paths)

I'm not sure what changed to trigger it, but searching for the error lead me to this 13 hour old PR, which seems like quite a coincidence. I'm on an M3 MacBook Air.

Edit: Thinking about it, I did update MacOS to 15.4 at the start of the week, and this is perhaps the first time I've run the tests locally since then. The tests run in debug mode, whereas I run the application itself in release mode which seems unaffected as @NoahR02 mentioned.

@xorgy
Copy link
Member
xorgy commented Apr 12, 2025

Ah, that'd do it. I rarely run in debug mode.

@xorgy xorgy changed the title FIX (FONTIQUE): Fix panic on macOS fontique: Fix panic on macOS in debug mode. Apr 14, 2025
xorgy
xorgy previously approved these changes Apr 17, 2025
Copy link
Member
@xorgy xorgy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but we want to check that this is still the best known solution.

@NoahR02
Copy link
Contributor Author
NoahR02 commented Apr 17, 2025

This works, but we want to check that this is still the best known solution.

The first image below shows the code panics when it goes into the objc2_foundation library / when we loop through the paths variable which calls its objc2 iterator. There may be a better overall solution, but that solution would have to be made in the objc2_* libraries themselves from what I know.

I searched their issues and pull requests and it seems like the relax-sign-encoding feature is currently still the only solution unless you want to iterate through it manually or make your own iterator as the author of the library mentions here: madsmtm/objc2#566 (comment) .


image

image

Copy link
Member
@xorgy xorgy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your submission, and your research on the topic.
Feel free to merge.

@DJMcNab DJMcNab added this pull request to the merge queue Apr 17, 2025
Merged via the queue into linebender:main with commit 56c5b6b Apr 17, 2025
21 checks passed
@NoahR02 NoahR02 deleted the bugfix/fix-panic-on-macos branch April 18, 2025 15:21
@xStrom xStrom added this to the 0.4 Release milestone May 7, 2025
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

Successfully merging this pull request may close these issues.

5 participants
0