-
Notifications
You must be signed in to change notification settings - Fork 90
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
clean MSAN warnings #131
base: master
Are you sure you want to change the base?
clean MSAN warnings #131
Conversation
1. Changed to "calloc" to create and initialize array. 2. Initialized `info` before being passed into blas package.
It's a little frustrating that MSan complains about passing a pointer to uninitialized data, even when it is an output buffer for the routine you are calling, as it is here. I'm worried that using In particular, suppose that you Maybe instead define a |
Thanks for the suggestion. Got your point. The explicit initialization is good to me. The only concern is that we have to manually add |
Yes, that's the point — when a memory sanitizer complains, this is an opportunity to manually check what is the correct initialization at that point in the code. The goal is not to silence the sanitizer, but to find and fix bugs. |
To avoid the warning of use-of-uninitialized-value from MSan and minimize the change to the original code, we changed`calloc` back to `malloc`, and initilize an array using `memset` at the place MSan complains.
Hi Prof. Johnson, please take another look, and let me know if this revision is good to you. Thanks. |
@@ -323,6 +324,7 @@ void sqmatrix_sqrt(sqmatrix Usqrt, sqmatrix U, sqmatrix W) | |||
CHECK(Usqrt.p == U.p && U.p == W.p, "matrices not conformant"); | |||
|
|||
CHK_MALLOC(eigenvals, real, U.p); | |||
memset(eigenvals, 0, sizeof(real) * U.p); |
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.
Shouldn't this be done in sqmatrix_eigensolve
, i.e. won't similar warnings come up on other calls to sqmatrix_eigensolve
if Msan doesn't understand LAPACK output variables?
Also should have a comment that that this initialization is not actually necessary, but is just to silence Msan.
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 agree that this is an incomplete solution to silence the MSan based on the unit tests provided from MEEP. It would give additional warnings if other similar functions are hit, e.g. sqmatrix_eigensolve
. It is quite hard to find all the MSan warnings without additional testing cases. Now maybe it is not necessary to silence warnings of use-of-uninitialized-value if you think calloc
is not a good solution. Please feel free to close this one and the other one if you agree to leave as it is. Thanks.
info
before being passed into blas package.