Closed ball-hayden closed 2 years ago
The simplification can be also done using macros only:
// With the Address Sanitizer enabled, the actual "original" `dispatch_x` are prepended with the
// word `wrap_`.
#if defined(__has_feature) && __has_feature(address_sanitizer)
# define DTX_ORIG_DISPATCH_NAME(type) [@"wrap_dispatch_" stringByAppendingString:type]
#else
# define DTX_ORIG_DISPATCH_NAME(type) [@"dispatch_" stringByAppendingString:type]
#endif
...
struct rebinding r[] = (struct rebinding[]) {
DTX_ORIG_DISPATCH_NAME(@"async"), __detox_sync_dispatch_async, (void**)&__orig_dispatch_async,
DTX_ORIG_DISPATCH_NAME(@"sync"), __detox_sync_dispatch_sync, (void**)&__orig_dispatch_sync,
...
};
I have no particular preference between these two, but I prefer one of them instead of the struct duplication.
Yeah - I was just looking at that.
String concatenation involves casting to an NSString and then trying to convince a cast back to const char*
for rebinding.
The macro appears to be neater - I'll push what I have shortly.
Looking great! But let's put the macros at the top of the file 🙂
@ball-hayden, can you please run another test with ASan enabled before we merge this?
Sorry @asafkorem - I missed your last message there. The app builds and launches now with ASan enabled.
Running the Detox e2e suite I see some failures, but I also see them against master
.
Thanks a lot @ball-hayden, amazing work 👑
Currently running with address sanitizer results in infinite recursion leading to a stack overflow.
With the address sanitizer enabled, the actual "original"
dispatch_x
s are prepended with the wordwrap_
.