-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Fix ASAN issues with std::function
usage
#4673
Conversation
Thank you so so so much for the quick response helping us with these issues from CRAN!!! I've created #4674 to track the discussion around this issue, and so we can reference it in the future. I think these changes look good, but I'd like to try to see if I can replicate the errors CRAN is reporting by following https://www.stats.ox.ac.uk/pub/bdr/memtests/README.txt, then test this PR with that setup. I'm going to attempt that tonight or tomorrow. |
I was able to reproduce the ASAN errors CRAN reported tonight. I tried those same steps on this branch to see if the changes here resolve the issue, and it seems that they don't. code I ran to test this branch with ASANgit clone \
--recursive \
--branch fptr \
[email protected]:david-cortes/LightGBM.git \
david-cortes-lgb
cd david-cortes-lgb
docker run \
--rm \
-v $(pwd):/usr/LightGBM \
--workdir /usr/LightGBM \
-it \
wch1/r-debug:latest \
/bin/bash
export ASAN_OPTIONS="detect_leaks=0:detect_odr_violation=0"
export UBSAN_OPTIONS="print_stacktrace=1"
export RJAVA_JVM_STACK_WORKAROUND=0
export RGL_USE_NULL=true
export R_DONT_USE_TK=true
RDscriptsan -e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())"
sh build-cran-package.sh
RDsan CMD INSTALL lightgbm_*.tar.gz
cd R-package/tests
RDscriptsan testthat.R >> tests.log 2>&1
# check that tests passed
echo "test exit code: $?"
tail -300 ./tests.log I see the same issue in logs as CRAN noted:
full logs
Could you take a look at the code I used above and see if you see any mistakes? If not, then this change probably does not fix the issue CRAN has noted. |
That's interesting - just noticed that CRAN shows two different errors, and the one I was thinking about was this: Perhaps there's another problem when it is not assigned a null pointer, but from a look at the trace, I'd venture to guess it could be a bug in the compiler header. Will investigate later. |
Did a bit more investigation:
|
std::function
usage
Thank you so much! Let's see what the CI jobs say about whether this change would break other things. I can also test with the |
closing and re-opening to retrigger CI, since we've recently fixed some configuration issues with Appveyor and Azure Pipelines jobs (#4675 (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.
I just tested this locally with the following code that seems to successfully reproduce CRAN's gcc-ASAN
and clang-ASAN
tests (as described in #4674 (comment) and in progress at #4678).
testing code (click me)
git clone \
--recursive \
--branch fptr \
[email protected]:david-cortes/LightGBM.git \
david-cortes-lgb
cd david-cortes-lgb
#
# options for CUSTOMIZATION:
#
# - "san" = gcc-ASAN
# - "csan" = clang-ASAN
#
docker run \
--rm \
-v $(pwd):/usr/LightGBM \
--workdir /usr/LightGBM \
--env CUSTOMIZATION=csan \
-it \
wch1/r-debug:latest \
/bin/bash
RDscript${CUSTOMIZATION} \
-e "install.packages(c('R6', 'data.table', 'jsonlite', 'Matrix', 'testthat'), repos = 'https://cran.r-project.org', Ncpus = parallel::detectCores())"
sh build-cran-package.sh
RD${CUSTOMIZATION} \
CMD INSTALL lightgbm_*.tar.gz
cd R-package/tests
rm -f ./tests.log
RDscript${CUSTOMIZATION} testthat.R >> tests.log 2>&1
# check that tests passed
echo "test exit code: $?"
tail -300 ./tests.log
No issues were raised by those tests as of the current state of this branch 🎉
So I'm confident that when {lightgbm}
3.3.1 is submitted, this change will resolve the errors CRAN has noted in clang-ASAN
and gcc-ASAN
checks.
Thanks so much for the help, @david-cortes !
Unfortunately, we are not testing CLI version at CI. |
This reverts commit 13ed38c.
This reverts commit 24c275b.
…ixes #4674) (#4678) * add jobs mimicking CRAN gcc-ASAN and clang-ASAN * comment out CI * fix redirection * remove unnecessary echo * Revert "comment out CI" This reverts commit 899fbb4. * remove redundant env variables and update README * remove inaccurate comment * change test title * Revert "Fix ASAN issues with `std::function` usage (#4673)" This reverts commit 13ed38c. * Revert "Revert "Fix ASAN issues with `std::function` usage (#4673)"" This reverts commit 24c275b. * revert unnecessary change in config order * Apply suggestions from code review Co-authored-by: Nikita Titov <[email protected]> Co-authored-by: Nikita Titov <[email protected]>
This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
The C API uses a C++
std::function
which gets compared against anullptr
to check if it assigned, which is not correct. This PR makes small changes to make the usage more idiomatic C++.I think this should fix the (or one of the) issue(s) highlighted by CRAN: #4633
But I'm not sure if this is all that was wrong or if there are more instances of usages like these, or if this will affect anything else other than the dataset construction in the C API.