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 asan support to cmake/nix #4194

Merged
merged 2 commits into from
Sep 19, 2023
Merged

Add asan support to cmake/nix #4194

merged 2 commits into from
Sep 19, 2023

Conversation

lrstewart
Copy link
Contributor

@lrstewart lrstewart commented Sep 10, 2023

Description of changes:

Subset of #4048 to allow builds that use cmake or nix to enable ASAN.

Call-outs:

This doesn't remove the existing CI builds that use make for ASAN. It just allows new builds to use cmake or nix for ASAN.

Testing:

I intentionally created a memory leak in s2n_ktls_io_test and used nix to run the test.

  • $ clean; S2N_CMAKE_OPTIONS="-DASAN=ON" configure output includes "Running tests with environment: S2N_DONT_MLOCK=1;S2N_ADDRESS_SANITIZER=1"
  • $ unit reports:
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 109
    Start 109: s2n_ktls_io_test

109: Test command: /home/ubuntu/s2n-tls/build/bin/s2n_ktls_io_test
109: Working Directory: /home/ubuntu/s2n-tls/tests/unit
109: Environment variables: 
109:  S2N_DONT_MLOCK=1
109:  S2N_ADDRESS_SANITIZER=1
109: Test timeout computed to be: 1500
109: 
109: =================================================================
109: ==1031096==ERROR: LeakSanitizer: detected memory leaks
109: 
109: Direct leak of 10 byte(s) in 1 object(s) allocated from:
109:     #0 0x7ffff768d7cf in __interceptor_malloc (/nix/store/5lp5v0sa76mhvc42bdc4z8vxwysp18r9-gcc-11.3.0-lib/lib/libasan.so.6+0xb17cf)
109:     #1 0x43a48c in s2n_mem_malloc_no_mlock_impl /home/ubuntu/s2n-tls/utils/s2n_mem.c:127
109:     #2 0x43af27 in s2n_realloc /home/ubuntu/s2n-tls/utils/s2n_mem.c:195
109:     #3 0x43b5b6 in s2n_alloc /home/ubuntu/s2n-tls/utils/s2n_mem.c:158
109:     #4 0x404566 in main /home/ubuntu/s2n-tls/tests/unit/s2n_ktls_io_test.c:156
109:     #5 0x7ffff6c0024d in __libc_start_call_main (/nix/store/9xfad3b5z4y00mzmk2wnn4900q0qmxns-glibc-2.35-224/lib/libc.so.6+0x2924d)
109: 
109: SUMMARY: AddressSanitizer: 10 byte(s) leaked in 1 allocation(s).
1/1 Test #109: s2n_ktls_io_test .................***Failed    1.69 sec

0% tests passed, 1 tests failed out of 1

Label Time Summary:
unit    =   1.69 sec*proc (1 test)

Total Test time (real) =   1.70 sec

The following tests FAILED:
	109 - s2n_ktls_io_test (Failed)
Errors while running CTest

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 Sep 10, 2023
@lrstewart lrstewart marked this pull request as ready for review September 11, 2023 21:56
@@ -23,6 +23,7 @@ function configure {
-DS2N_INSTALL_S2NC_S2ND=ON \
-DS2N_INTEG_NIX=ON \
-DBUILD_SHARED_LIBS=ON \
$S2N_CMAKE_OPTIONS \
Copy link
Contributor

Choose a reason for hiding this comment

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

Neat; this will be useful elsewhere.

@lrstewart lrstewart enabled auto-merge (squash) September 19, 2023 16:41
@lrstewart lrstewart merged commit 1640db5 into aws:main Sep 19, 2023
@lrstewart lrstewart deleted the asan branch September 19, 2023 20:33
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.

3 participants