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

[RNTester][IOS] Enable Address and Undefined Behavior Sanitizers #36443

Closed
wants to merge 5 commits into from

Conversation

Saadnajmi
Copy link
Contributor

Summary

This change does two things:

  1. Moves RNTester on iOS to use an .xctestplan to configure its tests. This moves the test configuration out of the .xcscheme file, and into a new json file that Xcode likes. It also allows you to run the same tests multiple times with different configurations. This was done by clicking the focused button below.

image

Note: this is partially me upstreaming a change from React Native macOS (microsoft#190), though at some point our Xcode project got messed up and we were no longer referencing them 🤷🏾.

  1. Enables Address Sanitizer and Udefined Behavior Sanitizer through the xctestplan

This should help catch some extra vulnerabilities should they ever show up while our tests run.

Notably, I did not also add a configuration to run Thread Sanitizer, because tests start failing with that enabled 😅.

Changelog

[IOS] [SECURITY] - Enable Address and Undefined Behavior Sanitizers on RNTester

Test Plan

CI should pass

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Microsoft Partner: Microsoft Partner labels Mar 10, 2023
@analysis-bot
Copy link

analysis-bot commented Mar 11, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,519,189 +0
android hermes armeabi-v7a 7,834,780 +0
android hermes x86 8,999,116 +0
android hermes x86_64 8,854,116 +0
android jsc arm64-v8a 9,141,839 +0
android jsc armeabi-v7a 8,333,495 +0
android jsc x86 9,196,443 +0
android jsc x86_64 9,454,253 +0

Base commit: 346de2d
Branch: main

@cipolleschi
Copy link
Contributor

Hi @Saadnajmi, thank you for the PR. I'll have a more thorough look at it on Monday, but currently the [RCTAnimationUtilsTests testColorInterpolation] test is failing consistently in CI. Could you have a look at it, please?

@Saadnajmi
Copy link
Contributor Author

Hi @Saadnajmi, thank you for the PR. I'll have a more thorough look at it on Monday, but currently the [RCTAnimationUtilsTests testColorInterpolation] test is failing consistently in CI. Could you have a look at it, please?

Sure. I'll take a look in the next day or two. I think I reproed the same crash locally but wasn't sure if it was local or acutally because I enabled the new sanitizers. It'll be interesting to see if we can make that test better now :)

@Saadnajmi
Copy link
Contributor Author

Saadnajmi commented Mar 16, 2023

For reference, the error I'm seeing locally is as follows:

=================================================================
==56710==ERROR: AddressSanitizer: odr-violation (0x000123ef2a80):
  [1] size=56 'folly::exception_wrapper::uninit_' react-native/packages/rn-tester/Pods/RCT-Folly/folly/ExceptionWrapper.cpp:25:52
  [2] size=56 'folly::exception_wrapper::uninit_' react-native/packages/rn-tester/Pods/Flipper-Folly/folly/ExceptionWrapper.cpp:25:52
These globals were registered at these points:
...

This seems to be similar to https://github.com/google/sanitizers/wiki/AddressSanitizerOneDefinitionRuleViolation
It looks like ASAN doesn't like we pull in Folly from both Flipper-Folly and RCT-Folly. This also explains why I didn't see the error in React Native macOS, we don't enable flipper by default.
Perhaps we only enable the sanitizer if flipper is not compiled? Working on it..

@Saadnajmi
Copy link
Contributor Author

Saadnajmi commented Mar 16, 2023

Nevermind, it's not Address Sanitizer at all. It's actually Undefined Behavior Sanitizer. See the error:
image

This can be fixed by casting to uint32_t instead. I pushed a fix up :)

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Great job, thank you for spending time in fixing the tests! :D

Let's see if the internal infra is happy about these changes! 😅

@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

Great stuff @Saadnajmi 👍

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Mar 20, 2023
@facebook-github-bot
Copy link
Contributor

@cipolleschi merged this pull request in 65e61f3.

@Saadnajmi Saadnajmi deleted the testplan branch March 20, 2023 17:42
jeongshin pushed a commit to jeongshin/react-native that referenced this pull request May 7, 2023
Summary:
This change does two things:

1) Moves RNTester on iOS to use an `.xctestplan` to configure its tests. This moves the test configuration out of the `.xcscheme` file, and into a new json file that Xcode likes. It also allows you to run the same tests multiple times with different configurations. This was done by clicking the focused button below.

![image](https://user-images.githubusercontent.com/6722175/224447314-49d460e9-d2d6-4ec9-9767-64c2a1c449c0.png)

Note: this is partially me upstreaming a change from React Native macOS (microsoft#190), though at some point our Xcode project got messed up and we were no longer referencing them ��.

2) Enables Address Sanitizer and Udefined Behavior Sanitizer through the xctestplan

This should help catch some extra vulnerabilities should they ever show up while our tests run.

Notably, I did not _also_ add a configuration to run Thread Sanitizer, because tests start failing with that enabled 😅.

## Changelog:

[IOS] [SECURITY] - Enable Address and Undefined Behavior Sanitizers on RNTester

Pull Request resolved: facebook#36443

Test Plan: CI should pass

Reviewed By: cortinico

Differential Revision: D44213517

Pulled By: cipolleschi

fbshipit-source-id: 0646174c4b416413a563e8178aa2cfca230b5e66
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
Summary:
This change does two things:

1) Moves RNTester on iOS to use an `.xctestplan` to configure its tests. This moves the test configuration out of the `.xcscheme` file, and into a new json file that Xcode likes. It also allows you to run the same tests multiple times with different configurations. This was done by clicking the focused button below.

![image](https://user-images.githubusercontent.com/6722175/224447314-49d460e9-d2d6-4ec9-9767-64c2a1c449c0.png)

Note: this is partially me upstreaming a change from React Native macOS (microsoft#190), though at some point our Xcode project got messed up and we were no longer referencing them ��.

2) Enables Address Sanitizer and Udefined Behavior Sanitizer through the xctestplan

This should help catch some extra vulnerabilities should they ever show up while our tests run.

Notably, I did not _also_ add a configuration to run Thread Sanitizer, because tests start failing with that enabled 😅.

## Changelog:

[IOS] [SECURITY] - Enable Address and Undefined Behavior Sanitizers on RNTester

Pull Request resolved: facebook#36443

Test Plan: CI should pass

Reviewed By: cortinico

Differential Revision: D44213517

Pulled By: cipolleschi

fbshipit-source-id: 0646174c4b416413a563e8178aa2cfca230b5e66
facebook-github-bot pushed a commit that referenced this pull request May 30, 2024
… tests (#44642)

Summary:
On React Native macOS (I am not sure with the current state of React Native), the Xcode Unit and Integration tests are a bit flaky. Rather than set "retry on failure up to 3 times" through the pipeline config (in our case, Azure Pipelines), I realized my earlier PR to use Xcode test plans (#36443) means we can have Xcode retry the test. This should be faster than retrying it on the pipeline, because it retries just the failing test, not the entire "test" step. I did this on React Native macOS, so I'm doing it upstream so we can remove a diff.

## Changelog:

[INTERNAL] [CHANGED] - Set `retryOnFailure` for Xcode Unit and Integration tests

Pull Request resolved: #44642

Test Plan: CI should pass (faster)

Reviewed By: cortinico

Differential Revision: D57662523

Pulled By: cipolleschi

fbshipit-source-id: 8de2ab0ea15ba4d38c3b5bf96108c0c7ff5e9f32
kosmydel pushed a commit to kosmydel/react-native that referenced this pull request Jun 11, 2024
… tests (facebook#44642)

Summary:
On React Native macOS (I am not sure with the current state of React Native), the Xcode Unit and Integration tests are a bit flaky. Rather than set "retry on failure up to 3 times" through the pipeline config (in our case, Azure Pipelines), I realized my earlier PR to use Xcode test plans (facebook#36443) means we can have Xcode retry the test. This should be faster than retrying it on the pipeline, because it retries just the failing test, not the entire "test" step. I did this on React Native macOS, so I'm doing it upstream so we can remove a diff.

## Changelog:

[INTERNAL] [CHANGED] - Set `retryOnFailure` for Xcode Unit and Integration tests

Pull Request resolved: facebook#44642

Test Plan: CI should pass (faster)

Reviewed By: cortinico

Differential Revision: D57662523

Pulled By: cipolleschi

fbshipit-source-id: 8de2ab0ea15ba4d38c3b5bf96108c0c7ff5e9f32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. p: Microsoft Partner: Microsoft Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants