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

strange bug in combination with malloc_count #18

Open
LukasNalbach opened this issue Jul 23, 2023 · 2 comments
Open

strange bug in combination with malloc_count #18

LukasNalbach opened this issue Jul 23, 2023 · 2 comments

Comments

@LukasNalbach
Copy link

LukasNalbach commented Jul 23, 2023

I am not sure where the root of this issue lies, but on some operating systems, a strange bug occurs when using libsais with OpenMP enabled in combination with malloc_count (https://github.com/bingmann/malloc_count) and gcc. I have not encountered any issues when using malloc_count in combination with any other library yet, so I suspected the issue might be linked to libsais and decided to post it here. I prepared a repository to illustrate it: https://github.com/LukasNalbach/libsais-malloc_count-bug

test-1.cpp uses malloc_count and libsais: Screenshot 2023-07-23 120025
test-2.cpp uses libsais without malloc_count and test-3.cpp uses malloc_count without libsais, no errors.

The bug does not occur when using clang. It also occurs in the sigle-thread version, as long as LIBSAIS_USE_OPENMP is set to ON. It seems to occurr regardless of the gcc and OpenMP versions used. For example, on Ubuntu 18.04 and 22.04 the bug occurs, but on 20.04 and 23.04 it does not. The issue does not occur when executing the program with valgrind with the options --tool=memcheck --leak-check=full.

Even just linking against (not including or calling) libsais when also using malloc_count can cause the same issue in a simple "#pragma omp parallel for" region, regardless of whether LIBSAIS_USE_OPENMP is set to ON. I have not been able to replicate this issue in the example repository, but for example, it occurs here: https://github.com/LukasNalbach/move-r/blob/b615972ca07ea4031416b7450bea65c762cc9e7d/include/move_r/algorithms/construction/modes/common.cpp#L12

edit: Setting THREAD_SAFE_GCC_INTRINSICS to 1 does not solve the issue.

@IlyaGrebnov
Copy link
Owner

From description it looks like an issue with GCC specific implementation of Open MP runtime. I am also not sure why it only suffuses with libsais.

@LukasNalbach
Copy link
Author

I found the solution to the problem, although I still do not understand why it does not always occur. It has nothing to do with libsais and has been fixed in ByteHamster-etc/malloc_count@f23b8c5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants