-
Notifications
You must be signed in to change notification settings - Fork 743
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
Address Sanitizer fix: remove fishhook dependency and hook C functions with GREYInterposer #201
base: master
Are you sure you want to change the base?
Conversation
e623d23
to
2e650d5
Compare
@@ -10,7 +10,8 @@ | |||
buildConfiguration = "Debug" | |||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | |||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | |||
shouldUseLaunchSchemeArgsEnv = "NO"> | |||
shouldUseLaunchSchemeArgsEnv = "NO" | |||
enableAddressSanitizer = "YES"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could have asan turned on for the Objective-C tests and off for the Swift ones, that way we could have both areas covered.
8176ed8
to
f7c6104
Compare
// GREYInterposerTuple must store exactly 2 pointers to be interchangable with tuples used in DYLD. | ||
typedef struct { | ||
const intptr_t _hook; | ||
const intptr_t _symbol; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe change hook to replacement based on the DYLD_INTERPOSE syntax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
f4c1b23
to
946e8d4
Compare
8b68c05
to
7eadf72
Compare
5f7caf1
to
27b5c86
Compare
Root cause for these issues was a bug in dyld_sim in 64-bit iOS 8.x simulators. Detailed description of the bug and its fix is in GREYInterposer.m. This code should now work properly. |
Thanks for the update @axi0mX . I will run it through internal tests |
a6e68bb
to
e3995d0
Compare
5a4c959
to
f4f71e6
Compare
We're using this branch over at PSPDFKit and I just re-based it for 1.9.2 - still works great. Are there any reasons this hasn't been pursued further? We run Address Sanitizer on all our tests, always, by default. It's just that good. |
hey Peter, apologies for the delay on this one. As I was trying to get it merged internally, I ran into some issues with Google's internal CI but now it seems to be resolved. I have made changes to this PR which need to be applied before I can merge it. @axi0mX can you give me commit privileges to I can make them directly and merge this hopefully by next week. |
This no longer works on iOS 11b1. The code is a bit over my head so not sure how to fix. There are 242 static tuples.
|
I've just updated to latest EarlGrey master (1.13+) and re-applied this patch. Should I try to clean this up for merging, or is there anything else planned? Running tests with ASan enabled is incredibly useful. |
This still works, we are using that with the 1.15 release. Is there any interest in getting this merged? |
Do you use this in production or for debugging mostly? |
We run all our tests with ASAN enabled by default, and can trigger TSAN enabled ones on request (both doesn't work together). That way we find more issues and races vs running tests without additional checks, especially for UI flow testing. |
That's interesting. I'll look into adding this for 2.0. |
We're still debating if we should migrate fully to EarlGrey from KIF. I'd love to read up on plans for 2.0, and what the major changes will be (XCUI bridge?) and if performance is something you're considering to improve + a timeline. |
@steipete Thanks for the performance comparison, I haven't done one myself between kif and eg. If you have a doc or so about your investigation, I'd love to take a look and see what areas could be improved. We don't take screenshots for every EG interaction - are you pointing to the Visibility Checker? We'll have docs explaining the design for EG 2 once we get the final release prepped. |
(I don't want to highjack this thread, if there's a better place to discuss, let me know) So a while back we decided that EarlGrey is better than KIF, has a more coherent API and better structure. However our KIF tests mostly just use busy waiting and run insanely fast. I disabled the syncing in EarlGrey:
We can enable this for most of our tests + some busy spinning to make things really fast, however the visibility checker does full-screen rendering, so our tests now max out CPU and are easily by a factor of 10x slower than a comparable KIF test. When looking at Instruments what takes up the majority of the time, it's the screen rendering + pixel comparison. Something KIF doesn't do. If visibility checking could opt out of this (by accepting that it might not be that accurate), we could probably get our testing time down from 15 to 5 or fewer minutes. |
Thanks for making us aware of that Peter...we're looking into speeding up EarlGrey 2 visibility checker this quarter. |
Instead of manually rebinding tables with fishhook, GREYInterposer uses DYLD's built-in interpose functionality to rebind symbols inside the dynamic linker.
DYLD interposing is also what Address Sanitizer uses to hook hundreds of C functions, including dispatch_after and dispatch_async.
The implementation should work when EarlGrey is linked statically into the main executable, but I did not test this use case. Please verify.
There are 4 use cases GREYInterposer considers for symbols that are statically interposed by Address Sanitizer. This requires using the macro which chains EarlGrey's interpose to Address Sanitizer's static interpose.
Resolves #194.