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

Consider disabling use_allocator_shim for apple builds #137

Closed
HeavenVolkoff opened this issue Oct 26, 2023 · 2 comments · Fixed by #138
Closed

Consider disabling use_allocator_shim for apple builds #137

HeavenVolkoff opened this issue Oct 26, 2023 · 2 comments · Fixed by #138

Comments

@HeavenVolkoff
Copy link
Contributor

HeavenVolkoff commented Oct 26, 2023

Hello,

I have recently started using the binaries produced by this project, and I think I stumbled into an issue related to the use of the allocator_shim in the builds for macOS.

My use case is to generate PDF thumbnails in a rust application through this crate. However, I started receiving complaints, from apple users, about somewhat constant crashes when the app started processing multiple PDFs due to an internal assert failing in the allocator_shim code:

image

After some investigation (with help from @brxken128) I found the code triggering the assert:

https://chromium.googlesource.com/chromium/src/base/allocator/partition_allocator/+/refs/heads/main/src/partition_alloc/shim/allocator_shim.cc#129

Which is an apple specific code that tries to find the memory zones that handled a specific allocation and then free it.

However, this code can fail in a specific use case (which somewhat matches mine) due to an open issue: https://crbug.com/1271139:

image

and related hacky work-around:

https://chromium.googlesource.com/chromium/src/base/allocator/partition_allocator/+/refs/heads/main/src/partition_alloc/shim/allocator_shim_override_apple_default_zone.h#224

image

I think the best solution, while this issue is not solved upstream, is for the allocator_shim to be disabled for apple builds, like it is already disabled for the linux builds:

case "$OS" in
ios)
echo "ios_enable_code_signing = false"
echo "use_blink = true"
[ "$ENABLE_V8" == "true" ] && [ "$TARGET_CPU" == "arm64" ] && echo 'arm_control_flow_integrity = "none"'
;;
linux)
echo 'use_allocator_shim = false'
;;
mac)
echo 'mac_deployment_target = "10.13.0"'
;;

However, if this is not desired for some reason, I think adding a notice in the README for people that use this lib in apple systems with dlopen could be an alternative.

P.S.: Thank you for maintaining this project, it is great and really useful

@bblanchon
Copy link
Owner

bblanchon commented Oct 26, 2023

Hi @HeavenVolkoff,

Thank you for reporting this issue; it sure sounds a like like #124.
Please open a PR.

Also, consider creating a second PR to add a link to your project on the README.

Best Regards,
Benoit

@HeavenVolkoff
Copy link
Contributor Author

Hun, we are also using libheif in our project, just like #124. Although, I don't think this is the same problem as the assert we are triggering is in an Apple specific part of the allocator_shim code, but it is a funny coincidence. Anyway, @bblanchon I opened a PR for disabling the allocator_shim in macOS builds #138 and another to add Spacedrive to the related projects #139, thank you for the suggestion.

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 a pull request may close this issue.

2 participants