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

Add ThreadSanitizer #4046

Merged
merged 5 commits into from
Jun 13, 2023
Merged

Add ThreadSanitizer #4046

merged 5 commits into from
Jun 13, 2023

Conversation

lrstewart
Copy link
Contributor

@lrstewart lrstewart commented Jun 9, 2023

Description of changes:

Adds ThreadSanitizer support to detect currency issues. We can enable it in the CI by adding:

   - identifier: ThreadSanitizer
      buildspec: codebuild/spec/buildspec_tsan.yml
      env:
        privileged-mode: true
        compute-type: BUILD_GENERAL1_LARGE
        image: 024603541914.dkr.ecr.us-west-2.amazonaws.com/docker:ubuntu22codebuild

To s2nGeneralBatch's buildspec.

Testing:

I'll post links to CodeBuild jobs as comments.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions bot added the s2n-core team label Jun 9, 2023
@lrstewart lrstewart force-pushed the tsan branch 2 times, most recently from 7579524 to fc6a581 Compare June 9, 2023 06:55
Copy link
Contributor Author

@lrstewart lrstewart left a comment

Choose a reason for hiding this comment

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

Comment on lines -523 to +538
set_property(
TEST
${test_case_name}
PROPERTY
ENVIRONMENT LD_PRELOAD=$<TARGET_FILE:allocator_overrides>)

set_property(
TEST
${test_case_name}
PROPERTY
ENVIRONMENT S2N_DONT_MLOCK=1)
set_property(TEST ${test_case_name} PROPERTY ENVIRONMENT ${UNIT_TEST_ENVS})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting ENVIRONMENT like this overrides instead of appends. So the first call to set LD_PRELOAD has no affect on how the tests are ultimately run, but the call to S2N_DONT_MLOCK does. CMake 3.22 added ENVIRONMENT_MODIFICATION to support modifying instead of completely overriding, but our CI uses some very old versions of CMake and we shouldn't assume our customers are using the latest either.

I fixed this problem by constructing the full set of environment variables as a string so that I could set ENVIRONMENT once.

@lrstewart lrstewart marked this pull request as ready for review June 9, 2023 08:35
@lrstewart lrstewart requested a review from dougch as a code owner June 9, 2023 08:35
@lrstewart lrstewart requested a review from jmayclin June 9, 2023 08:35
CMakeLists.txt Show resolved Hide resolved
post_build:
on-failure: ABORT
commands:
- CTEST_OUTPUT_ON_FAILURE=1 CTEST_PARALLEL_LEVEL=$(nproc) make -C build test
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Would it make sense to add this to the environment variables that you set in the CMakeLists.txt? That way all of our CI would get it for free. It would make it hard to suppress failed test output, but that doesn't seem like something that would ever be necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh that's a good idea! Then we don't have to remember it everywhere. I'll do that in a separate PR.

@lrstewart lrstewart enabled auto-merge (squash) June 12, 2023 20:03
@lrstewart lrstewart merged commit b4aee0c into aws:main Jun 13, 2023
25 checks passed
@lrstewart lrstewart deleted the tsan branch June 13, 2023 00:55
dougch pushed a commit to dougch/s2n-tls that referenced this pull request Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants