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

empty ranges for concurrent_map and concurrent_unordered_map cause crash / assert #641

Closed
NikolausDemmel opened this issue Nov 5, 2021 · 2 comments · Fixed by #703
Closed
Assignees
Labels

Comments

@NikolausDemmel
Copy link

Ranges can be empty, right?

I'm seeing strange behaviour of range() called on empty containers of type tbb::concurrent_map() and tbb::concurrent_unordered_map leading to crashes or infinite loops. Is that expected?

In the following minimal working example an assert is triggered in Debug mode and an infinite loop occurs in Release:

#include <tbb/concurrent_unordered_map.h>
//#include <tbb/concurrent_map.h>

#include <iostream>

int main() {
  tbb::concurrent_unordered_map<int, int> map;
  // tbb::concurrent_map<int, int> map;

  // map[1] = 2;

  auto range = map.range();

  std::cout << range.empty() << std::endl;
}

Assert:

Assertion bucket != 0 failed (located in the get_parent function, line in file: 1445)
Detailed description: Unable to get_parent of the bucket 0

If I uncomment the line map[1] = 2;, it runs fine. If I switch to tbb::concurrent_map, I get a segfault somewhere in _concurrent_skip_list.h.

This is on macOS 10.15 (Catalina) with TBB 2021.4.0 from Homebrew. Same behaviour with Apple clang version 12.0.0 from XCode or clang 13 from Homebrew.

@NikolausDemmel
Copy link
Author

PS: A quick test on Ubuntu 18.04 with GCC 7.5 and TBB 2017.0 does work fine with empty containers.

Here is a minimal working example cmake project: https://github.com/NikolausDemmel/tbb_test

@kboyarinov kboyarinov self-assigned this Nov 8, 2021
@kboyarinov kboyarinov added the bug label Nov 8, 2021
@kboyarinov
Copy link
Contributor

Hi, @NikolausDemmel,

Thank you for reporting the issue! It seems like the oneTBB C++11 implementation of both ordered and unordered containers contains an issue in case of empty ranges. We will work on this issue and provide the solution in one of the future oneTBB releases. Thank you once again.

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