mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
c2ac0cc72a
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41401 Changelog: [Internal] When build Cxx Turbo Modules with Clang's ASAN build mode the apps are crashing at runtime due to, e.g.: ``` runtime error: downcast of address 0x00010dafd618 which does not point to an object of type 'facebook::react::NativePerformance' 0x00010dafd618: note: object is of type 'facebook::react::NativePerformanceCxxSpec<facebook::react::NativePerformance>' 00 00 00 00 f0 08 49 06 01 00 00 00 4e 61 74 69 76 65 50 65 72 66 6f 72 6d 61 6e 63 65 43 78 78 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'facebook::react::NativePerformanceCxxSpec<facebook::react::NativePerformance>' UndefinedBehaviorSanitizer: undefined-behavior FBReactNativeSpecJSI.h:6122:17 ``` Where the corresponding generated code looks like ``` NativePerformanceCxxSpec(std::shared_ptr<CallInvoker> jsInvoker) : TurboModule(std::string{NativePerformanceCxxSpec::kModuleName}, jsInvoker), delegate_(static_cast<T*>(this), jsInvoker) {} ``` This change fixes that problem AddressSanitizer: stack-use-after-scope shared_ptr.h:634 in std::__1::shared_ptr<facebook::react::InstanceHandle const>::shared_ptr[abi:v160006](std::__1::shared_ptr<facebook::react::InstanceHandle const> const&) Shadow bytes around the buggy address: 0x00016cea4a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x00016cea4b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x00016cea4b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x00016cea4c00: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 f8 f8 f8 f8 0x00016cea4c80: f8 f8 f2 f2 f2 f2 f8 f8 f2 f2 00 00 f2 f2 f8 f8 =>0x00016cea4d00: f2 f2 f8 f8 f2 f2 00 00 f2 f2[f8]f8 f2 f2 00 00 0x00016cea4d80: f2 f2 f8 f8 f2 f2 f8 f8 f2 f2 f8 f8 f8 f2 f2 f2 0x00016cea4e00: f2 f2 f8 f8 f2 f2 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 0x00016cea4e80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f2 f2 f2 f2 f2 f2 f2 0x00016cea4f00: f2 f2 f8 f8 f3 f3 f3 f3 00 00 00 00 00 00 00 00 0x00016cea4f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==41992==ABORTING ``` Reviewed By: rshest Differential Revision: D51183328 fbshipit-source-id: 5aff5b5eecb9d78f9b7438fbdda2c01625c9a4d9