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 hash function for 64 bit units base #150

Merged
merged 2 commits into from
Apr 19, 2021

Conversation

SimonHeybrock
Copy link
Contributor

@SimonHeybrock SimonHeybrock commented Apr 19, 2021

With -DUNITS_BASE_TYPE=int64_t the hash function only hashed the first 32 bit of unit_data. This led to identical hashes for different units.

See added unit test, which should fail before the fix put always passed for 32 bit unit_data width.

Fixes scipp/scipp#1829.

@codecov-commenter
Copy link

Codecov Report

Merging #150 (bc5a381) into master (04f4006) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #150   +/-   ##
=======================================
  Coverage   99.25%   99.25%           
=======================================
  Files           6        6           
  Lines        4808     4808           
=======================================
  Hits         4772     4772           
  Misses         36       36           

@phlptp
Copy link
Collaborator

phlptp commented Apr 19, 2021

Thanks,
Seeing this makes me realize I need to add a static assert that the UNITS_BASE_TYPE is either 4 or 8 bytes, otherwise this hash has the potential to seg fault.

@phlptp phlptp merged commit e40d208 into LLNL:master Apr 19, 2021
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

Successfully merging this pull request may close these issues.

Segfault with llnl units via convert on one (known) platform
3 participants