You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "andygrove (via GitHub)" <gi...@apache.org> on 2024/06/11 13:24:40 UTC
[PR] fix: Remove unsafe uses of from_raw_parts from crc32 and murmur hash functions [datafusion-comet]
andygrove opened a new pull request, #554:
URL: https://github.com/apache/datafusion-comet/pull/554
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
Part of https://github.com/apache/datafusion-comet/issues/507
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
Remove unsafe uses of from_raw_parts. This code fails in a debug assertion when we upgrade to Rust 1.78.
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
## How are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: Remove unsafe uses of from_raw_parts from crc32 and murmur hash functions [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #554:
URL: https://github.com/apache/datafusion-comet/pull/554#discussion_r1634891448
##########
core/src/parquet/util/hash_util.rs:
##########
@@ -106,16 +110,12 @@ unsafe fn crc32_hash(bytes: &[u8], seed: u32) -> u32 {
let num_words = num_bytes / u32_num_bytes;
num_bytes %= u32_num_bytes;
- let bytes_u32: &[u32] = std::slice::from_raw_parts(
- &bytes[0..num_words * u32_num_bytes] as *const [u8] as *const u32,
- num_words,
- );
Review Comment:
This violates a precondition for `from_raw_parts` because `bytes` is not guaranteed to be correctly aligned for `u32`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: Remove unsafe uses of from_raw_parts from crc32 and murmur hash functions [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove closed pull request #554: fix: Remove unsafe uses of from_raw_parts from crc32 and murmur hash functions
URL: https://github.com/apache/datafusion-comet/pull/554
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: Remove unsafe uses of from_raw_parts from crc32 and murmur hash functions [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #554:
URL: https://github.com/apache/datafusion-comet/pull/554#discussion_r1634890732
##########
core/src/parquet/util/hash_util.rs:
##########
@@ -45,17 +47,19 @@ const MURMUR_R: i32 = 47;
unsafe fn murmur_hash2_64a(data_bytes: &[u8], seed: u64) -> u64 {
let len = data_bytes.len();
let len_64 = (len / 8) * 8;
- let data_bytes_64 =
- std::slice::from_raw_parts(&data_bytes[0..len_64] as *const [u8] as *const u64, len / 8);
Review Comment:
This violates a precondition for `from_raw_parts` because `data_bytes` is not guaranteed to be correctly aligned for `u64`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: Remove unsafe uses of from_raw_parts from crc32 and murmur hash functions [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #554:
URL: https://github.com/apache/datafusion-comet/pull/554#issuecomment-2163186608
I found out that none of this code is actually used in Comet, so I am deleting it in https://github.com/apache/datafusion-comet/pull/561
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: Remove unsafe uses of from_raw_parts from crc32 and murmur hash functions [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #554:
URL: https://github.com/apache/datafusion-comet/pull/554#issuecomment-2161653901
Moving to draft until I have criterion benchmarks in place
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org