Realtime fnv1a_hash sign-extends char, so a non-ASCII handler name gets a platform-dependent function id

Open Beginner friendly
#6,029 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@fedonman is already working on this.

Since Dec 3, 2026.

  • #6030 by @fedonman — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
77/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp
Domain
backend

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

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NVIDIA/cuda-quantum

All issues in NVIDIA/cuda-quantum

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.