-
Notifications
You must be signed in to change notification settings - Fork 66
ci: add asan and ubsan support #107
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
Conversation
It seems that the flags for sanitizers are leaked into thirdparty builds. We need to use target-based compile properties like below: |
.github/workflows/sanitizer_test.yml
Outdated
| env: | ||
| CC: ${{ matrix.cc }} | ||
| CXX: ${{ matrix.cxx }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this defined in the matrix?
raulcd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Some minor comments, in general LGTM
| concurrency: | ||
| group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} | ||
| cancel-in-progress: true | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add contents read permissions:
permissions:
contents: read
.github/workflows/sanitizer_test.yml
Outdated
| CXX: ${{ matrix.cxx }} | ||
| run: | | ||
| mkdir build && cd build | ||
| cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DICEBERG_ENABLE_ASAN=ON -DICEBERG_ENABLE_UBSAN=ON |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CMAKE_EXPORT_COMPILE_COMMANDS=ON seems to be the default, is it necessary to explicitly be set here?
Line 34 in e70d2ca
| set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| - name: Run Tests | ||
| working-directory: build | ||
| env: | ||
| ASAN_OPTIONS: log_path=out.log:detect_leaks=1:symbolize=1:strict_string_checks=1:halt_on_error=0:detect_container_overflow=0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we upload the output logs on the job? or should we remove the log_path=out.log if not used?
- name: Save the test output
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: test-output
path: out.logThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all comments has done. ths
cmake_modules/IcebergSanitizer.cmake
Outdated
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| # Sanitize check for address and undefined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # Sanitize check for address and undefined. |
I think this is redundant
.github/workflows/sanitizer_test.yml
Outdated
| contents: read | ||
|
|
||
| jobs: | ||
| asan-test: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| asan-test: | |
| sanitizer-test: |
cmake_modules/IcebergSanitizer.cmake
Outdated
| if(ICEBERG_ENABLE_ASAN OR ICEBERG_ENABLE_UBSAN) | ||
| add_library(iceberg_sanitizer_flags INTERFACE) | ||
| set(SANITIZER_FLAGS iceberg_sanitizer_flags) | ||
| endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if(ICEBERG_ENABLE_ASAN OR ICEBERG_ENABLE_UBSAN) | |
| add_library(iceberg_sanitizer_flags INTERFACE) | |
| set(SANITIZER_FLAGS iceberg_sanitizer_flags) | |
| endif() | |
| add_library(iceberg_sanitizer_flags INTERFACE) |
It is much simpler to make it available at all times even without any flag.
| if(TARGET ${SANITIZER_FLAGS}) | ||
| target_link_libraries(${LIB_NAME}_shared | ||
| PRIVATE "$<BUILD_INTERFACE:${SANITIZER_FLAGS}>") | ||
| endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if(TARGET ${SANITIZER_FLAGS}) | |
| target_link_libraries(${LIB_NAME}_shared | |
| PRIVATE "$<BUILD_INTERFACE:${SANITIZER_FLAGS}>") | |
| endif() | |
| target_link_libraries(${LIB_NAME}_shared | |
| PUBLIC "$<BUILD_INTERFACE:iceberg_sanitizer_flags>") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be visible to downstream targets (e.g. unit tests) as well.
| if(TARGET ${SANITIZER_FLAGS}) | ||
| target_link_libraries(${LIB_NAME}_static | ||
| PRIVATE "$<BUILD_INTERFACE:${SANITIZER_FLAGS}>") | ||
| endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if(TARGET ${SANITIZER_FLAGS}) | |
| target_link_libraries(${LIB_NAME}_static | |
| PRIVATE "$<BUILD_INTERFACE:${SANITIZER_FLAGS}>") | |
| endif() | |
| target_link_libraries(${LIB_NAME}_static | |
| PUBLIC "$<BUILD_INTERFACE:iceberg_sanitizer_flags>") |
wgtmac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 Thanks!
|
I am slightly confused, the log output from the job, see the artifact uploaded here: Shouldn't the CI job fail? I might be misinterpreting but I would expect the job to fail if a leak is found (as it seems is found from the logs) |
| - name: Run Tests | ||
| working-directory: build | ||
| env: | ||
| ASAN_OPTIONS: log_path=out.log:detect_leaks=1:symbolize=1:strict_string_checks=1:halt_on_error=0:detect_container_overflow=0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ASAN_OPTIONS: log_path=out.log:detect_leaks=1:symbolize=1:strict_string_checks=1:halt_on_error=0:detect_container_overflow=0 | |
| ASAN_OPTIONS: log_path=out.log:detect_leaks=1:symbolize=1:strict_string_checks=1:halt_on_error=1:detect_container_overflow=0 |
@raulcd Perhaps we need to enable halt_on_error to avoid the errors being swallowed by the log files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raulcd currently we set halt_on_error=0 to not blocking the test, and will fix all leaks later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll let @wgtmac and yourself decide but I would rather merge a failing CI job on this case, knowing that it has to be fixed on a subsequent PR, than a false positive.
.github/workflows/sanitizer_test.yml
Outdated
| env: | ||
| ASAN_OPTIONS: log_path=out.log:detect_leaks=1:symbolize=1:strict_string_checks=1:halt_on_error=0:detect_container_overflow=0 | ||
| LSAN_OPTIONS: suppressions=${{ github.workspace }}/.github/lsan-suppressions.txt | ||
| UBSAN_OPTIONS: log_path=out.log:print_stacktrace=1:suppressions=${{ github.workspace }}/.github/ubsan-suppressions.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| UBSAN_OPTIONS: log_path=out.log:print_stacktrace=1:suppressions=${{ github.workspace }}/.github/ubsan-suppressions.txt | |
| UBSAN_OPTIONS: log_path=out.log:halt_on_error=1:print_stacktrace=1:suppressions=${{ github.workspace }}/.github/ubsan-suppressions.txt |
|
I would suggest to do the following:
|
That makes sense to me. To validate that the PR actually will fail the CI job and then open an issue to fix the sanitizer issues and turn on the Thanks @wgtmac |
|
https://github.com/apache/iceberg-cpp/actions/runs/15329887114/job/43133746854?pr=107 confirmed that this PR works as expected. |
|
Now we can go with either approach:
Please feel free to choose one @METONLIULEI |
|
@wgtmac already reset halt_on_error=0 now. and fix all issues in the next PR. |
wgtmac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Please fix the PR title to ci: add asan and ubsan support
raulcd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for validating!
Fokko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too deep into C++ for me, but I trust on @wgtmac, @raulcd and @lidavidm expertise here, thanks for adding this @METONLIULEI
Co-authored-by: lei.liu <[email protected]>
No description provided.