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

Is this a bug in hash.h#81 HashBuffer()? #487

Open
laiyongfei2024 opened this issue Feb 11, 2025 · 0 comments
Open

Is this a bug in hash.h#81 HashBuffer()? #487

laiyongfei2024 opened this issue Feb 11, 2025 · 0 comments

Comments

@laiyongfei2024
Copy link

https://github.com/mmp/pbrt-v4/blob/779d1a78b74aab393853544198189729434121b5/src/pbrt/util/hash.h#L81C33-L81C42

template <typename T>
PBRT_CPU_GPU inline uint64_t HashBuffer(const T *ptr, size_t size, uint64_t seed = 0) {
    return MurmurHash64A((const unsigned char *)ptr, size, seed);
}
PBRT_CPU_GPU inline uint64_t MurmurHash64A(const unsigned char *key, size_t len,
                                           uint64_t seed) {
    const uint64_t m = 0xc6a4a7935bd1e995ull;
    const int r = 47;

    uint64_t h = seed ^ (len * m);

    const unsigned char *end = key + 8 * (len / 8);

In the function HashBuffer(), the pointer ptr is converted to unsigned char * type, but the size is element size, not byte size. So in MurmurHash64A(), the end is not the real end of the data.

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

1 participant