Realtime fnv1a_hash sign-extends char, so a non-ASCII handler name gets a platform-dependent function id
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 77/100
Research direction
Start with realtime/include/cudaq/realtime/daemon/dispatcher/dispatch_kernel_launch.h, which the reproduction includes, and inspect fnv1a_hash alongside the cc.device_call lowering described in the issue. Add a focused test for a non-ASCII handler name and compare its hash with the expected byte-based FNV-1a value; done means the id matches across signed- and unsigned-char platforms while ASCII ids remain unchanged.
Written by the indexing model from the issue text.
Description
Required prerequisites
- Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
- If possible, make a PR with a failing test to give us a starting point to work on!
Describe the bug
cudaq::realtime::fnv1a_hash XORs static_cast<std::uint32_t>(*str) into the hash. char is signed on x86_64, so a byte at or above 0x80 is sign-extended before the XOR. A handler name with a non-ASCII character therefore gets a different function id on x86_64 than on aarch64, and a different one from the cc.device_call lowering, which hashes unsigned bytes through llvm::getKCFITypeID(callee, FNV1a). The request then matches no handler and is dropped. ASCII names are not affected.
Steps to reproduce the bug
#include "cudaq/realtime/daemon/dispatcher/dispatch_kernel_launch.h"
#include <cstdio>
int main() {
std::printf("0x%08X\n", cudaq::realtime::fnv1a_hash("décode"));
}
Built with g++ -Irealtime/include on x86_64 this prints 0xB45CFA82. With -funsigned-char, the aarch64 default, it prints 0x26F8C282.
Expected behavior
The same id on every platform, equal to standard FNV-1a over the name's bytes: 0x26F8C282 for décode.
Is this a regression? If it is, put the last known working version (or commit) here.
Not a regression
Environment
- CUDA-Q version: main at 2c37740
- C++ compiler: GCC 15.2 (x86_64)
- Operating system: Ubuntu 26.04
Suggestions
Cast through an unsigned byte: hash ^= static_cast<std::uint8_t>(*str++);. No ASCII id changes.
- Dominant language
- C++
- Stars
- 1.2k
- Forks
- 508
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 100
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NVIDIA/cuda-quantum
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
NVIDIA/cuda-quantum#6035 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 77/100
NVIDIA/cuda-quantum#6034 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-quantum#6033 ·
Maintainers usually reply within 1 day
-
Point the CUDA-Q Pulse research preview docs to the released cudaq-pulse packagePossibly taken @fedonman claimed this 2 days ago. Open
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
NVIDIA/cuda-quantum#6031 ·
Maintainers usually reply within 1 day
-
SyntaxWarning in test_Quantinuum_kernel.py: use equality check rather than identity on string literalPossibly taken @sisco0 claimed this 7 days ago. Openstale-notified
Difficulty 1/5 Under an hour Newbie friendliness 94/100
NVIDIA/cuda-quantum#5952 · 2 comments ·
Maintainers usually reply within 1 day
All issues in NVIDIA/cuda-quantum
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 2 days
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ClickHouse/clickhouse-cpp#645 ·
Maintainers usually reply within 1 day
-
bug compatibility difficulty:easy prio:normal
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NatronGitHub/openfx-misc#524 ·
Maintainers usually reply within 1 day
-
documentation enhancement help wanted P0
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Awesome-Embedded-Learning-Studio/Tutorial_AwesomeModernCPP#359 ·
Maintainers usually reply within 1 day
-
Type: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
openscad/openscad#7360 · 2 comments ·
Maintainers usually reply within 1 day