Skip to content

Comments

i#5383: Fix macOS preload on a64#7170

Merged
edeiana merged 21 commits intoDynamoRIO:masterfrom
ndrewh:i5383-macos-14-4-preload
Jan 16, 2025
Merged

i#5383: Fix macOS preload on a64#7170
edeiana merged 21 commits intoDynamoRIO:masterfrom
ndrewh:i5383-macos-14-4-preload

Conversation

@ndrewh
Copy link
Contributor

@ndrewh ndrewh commented Dec 26, 2024

This fixes several build and runtime issues under macOS on ARM64 on macOS 14.4.1 (Sonoma)

  • FEATURE_PAUTH is now detected on macOS using a sysctl (capability MSRs cannot be read in userspace on M3 at least)
  • In the preload library and os.c, _init needs __attribute__((constructor)) to be run by dyld
  • PLATFORM_SUPPORTS_SCATTER_GATHER is broken, disabled for now on a64 macOS
  • Fixed sigcontext/mcontext conversion which assumes old simd size and was failing on an assert

Known issues that remain:

  • VM allocation frequently but nondeterministically fails reachability constraints. -vm_size 500M seems to fix this. i#5383: Fix macOS arm64 test build/run #7171 adds this flag to tests on macOS+ARM64. Another option is to make this the default on macOS+ARM64.
  • Sometimes some bookkeeping asserts in vmh_exit are reached upon process exit

The end result is that the bbcount tool works on a simple toy program on macOS, in debug mode, without hitting any asserts:

bin64/drrun -debug -vm_size 500M -c api/bin/libbbcount.dylib -- ./main

Issue #5383

@ndrewh
Copy link
Contributor Author

ndrewh commented Dec 26, 2024

It appears I broke the x86 macOS tests, not sure what's going on there yet

@ndrewh ndrewh changed the title i#5383: Fix macOS hello world on a64 i#5383: Fix macOS preload on a64 Dec 26, 2024
@abhinav92003
Copy link
Contributor

It appears I broke the x86 macOS tests, not sure what's going on there yet

If it helps: check out the "Debugging Tests on Github Actions Runner" section at https://dynamorio.org/page_test_suite.html, which documents a way to ssh into the failing test machine.

@ndrewh
Copy link
Contributor Author

ndrewh commented Dec 27, 2024

Alright somehow adding IF_MACOS(__attribute__((constructor))) to the _init function in preload.c is breaking the x86 tests. I can't say I understand the situation at all:

  • on ARM64 macOS 14.4 the preload doesn't work at all without __attribute__((constructor)), which causes ~all of the client tests to fail
  • on the x86 macOS runner (which is on macOS 13):
    • All of the tests seem to pass without the attribute (??? did dyld stop running _init in macOS 14? I searched https://github.com/apple-oss-distributions/dyld and i'm not seeing where they ever ran _init -- maybe some compilers were automatically putting it in the appropriate section but recently changed this behavior?)
    • Once you add the attribute some (but not all!) of the client tests fail with some seemingly random instrumentation assert.

@ndrewh
Copy link
Contributor Author

ndrewh commented Dec 27, 2024

I don't think api.startstop fail is my fault, but I also don't see anything to suggest it's #6928

Copy link
Contributor

@edeiana edeiana left a comment

Choose a reason for hiding this comment

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

Add "Issue #5383" at the end of the PR description as suggested in the commit template.

(Thank you for contributing in making DynamoRIO work better on MacOS!)

@ndrewh ndrewh requested a review from edeiana January 6, 2025 08:27
@ndrewh
Copy link
Contributor Author

ndrewh commented Jan 15, 2025

@edeiana I don't have permissions to merge it myself, actually

@edeiana
Copy link
Contributor

edeiana commented Jan 16, 2025

You're right, apologies for the confusion, I'll merge this one then.
Thank you again for contributing!

@edeiana edeiana merged commit 359868c into DynamoRIO:master Jan 16, 2025
17 checks passed
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.

3 participants