Skip to content

Fix wrong MSAN errors.#21527

Merged
alalek merged 2 commits intoopencv:3.4from
vrabaud:3.4_msan
Jan 28, 2022
Merged

Fix wrong MSAN errors.#21527
alalek merged 2 commits intoopencv:3.4from
vrabaud:3.4_msan

Conversation

@vrabaud
Copy link
Copy Markdown
Contributor

@vrabaud vrabaud commented Jan 27, 2022

Because Fortran is called in Lapack, MSAN does not think the memory
has been written even though it is the case.
MSAN does no support well cross-language memory analysis.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch

Because Fortran is called in Lapack, MSAN does not think the memory
has been written even though it is the case.
MSAN does no support well cross-language memory analysis.
else if(typeid(fptype) == typeid(double))
OCV_LAPACK_FUNC(dgesdd)(mode, &m, &n, (double*)a, &lda, (double*)w, (double*)u, &ldu, (double*)vt, &ldv, (double*)buffer, &lwork, iworkBuf, info);

#if defined(__clang__) && defined(__has_feature) && __has_feature(memory_sanitizer)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

defined(__has_feature)

should be a dedicated check

#if defined(__clang__) && defined(__has_feature)
  #if __has_feature(memory_sanitizer)
  #endif
#endif

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@vrabaud
Copy link
Copy Markdown
Contributor Author

vrabaud commented Jan 27, 2022

BTW, we could probably create a macro at some point like in absl https://github.com/abseil/abseil-cpp/blob/e3fdd9b16a2a90c9e01e00de46605ce59bebc661/absl/base/dynamic_annotations.h#L242
I only fixed the function I cared about but I imagine any Lapack call will probably trigger MSAN.

@alalek alalek merged commit b5b52af into opencv:3.4 Jan 28, 2022
@alalek alalek mentioned this pull request Jan 28, 2022
@vrabaud vrabaud deleted the 3.4_msan branch January 31, 2022 10:59
vrabaud added a commit to vrabaud/opencv that referenced this pull request Feb 10, 2022
This is similar to opencv#21527
A macro is also created to simplify the code.
@vrabaud vrabaud mentioned this pull request Feb 10, 2022
4 tasks
rogday pushed a commit to rogday/opencv that referenced this pull request Feb 17, 2022
* Fix wrong MSAN errors.

Because Fortran is called in Lapack, MSAN does not think the memory
has been written even though it is the case.
MSAN does no support well cross-language memory analysis.

* Make a dedicated check.
@alalek alalek mentioned this pull request Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants