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

Fix UBSan issue #1615

Merged
merged 3 commits into from
Jan 28, 2025
Merged

Fix UBSan issue #1615

merged 3 commits into from
Jan 28, 2025

Conversation

dnmokhov
Copy link
Contributor

Description

UBSan reports an error if we try to downcast a misaligned address. To avoid it, we need to check if an address is valid before casting it.

Here is the UBSan error:

concurrent_hash_map.h:470:62: runtime error: downcast of misaligned address 0x000000000003 for type 'node' (aka 'tbb::detail::d2::concurrent_hash_map<int, int>::node'), which requires 8 byte alignment
0x000000000003: note: pointer points here
<memory cannot be printed>
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior concurrent_hash_map.h:470:62

Fixes #1601

Type of change

  • bug fix - change that fixes an issue
  • new feature - change that adds functionality
  • tests - change in tests
  • infrastructure - change in infrastructure and CI
  • documentation - documentation update

Tests

  • added - required for new features and some bug fixes
  • not needed

Documentation

  • updated in # - add PR number
  • needs to be updated
  • not needed

Breaks backward compatibility

  • Yes
  • No
  • Unknown

Signed-off-by: Dmitri Mokhov <[email protected]>
Copy link
Contributor

@kboyarinov kboyarinov left a comment

Choose a reason for hiding this comment

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

LGTM

@dnmokhov dnmokhov merged commit 3c85ad7 into master Jan 28, 2025
25 checks passed
@dnmokhov dnmokhov deleted the dev/dnmokhov/valid_node branch January 28, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clang UBSan alignment error in tbb::concurrent_hash_map::hash_map_iterator constructor
2 participants