Skip to content

Shifting long long value more than 63 bits is UB#580

Open
zhengyu123 wants to merge 1 commit into
mainfrom
zgu/shift-ub
Open

Shifting long long value more than 63 bits is UB#580
zhengyu123 wants to merge 1 commit into
mainfrom
zgu/shift-ub

Conversation

@zhengyu123
Copy link
Copy Markdown
Contributor

What does this PR do?:
Shifting long long value more than 63 bits is UB, break out the loop before shift reaches invalid value.

Besides, the fix matching the HASH macro's highest term s[11] << 55.

Motivation:
Improve stability and correctness.

Additional Notes:

How to test the change?:
fuzz_arguments test now passes.

For Datadog employees:

  • If this PR touches code that signs or publishes builds or packages, or handles
    credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.
  • JIRA: PROF-14936

Unsure? Have a question? Request a review!

@zhengyu123 zhengyu123 requested a review from a team as a code owner June 5, 2026 18:40
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18fd9576da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

long long Arguments::hash(const char *arg) {
long long h = 0;
for (int shift = 0; *arg != 0; shift += 5) {
for (int shift = 0; *arg != 0 && shift < 60; shift += 5) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject overlong option suffixes

For arguments longer than 12 characters, this now silently ignores the rest of the option name, so malformed inputs whose first twelve bytes collide with a valid CASE are accepted instead of being recorded as _unknown_arg. For example, start x hashes the same as start because the seven spaces occupy the remaining hashed slots and the trailing x is discarded, which sets ACTION_START with no unknown-argument warning; overlong names should instead produce a non-matching hash once *arg remains after the 12th character.

Useful? React with 👍 / 👎.

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented Jun 5, 2026

CI Test Results

Run: #27033368721 | Commit: e42ac42 | Duration: 12m 17s (longest job)

All 32 test jobs passed

Status Overview

JDK glibc-aarch64/debug glibc-amd64/debug musl-aarch64/debug musl-amd64/debug
8 - - -
8-ibm - - -
8-j9 - -
8-librca - -
8-orcl - - -
11 - - -
11-j9 - -
11-librca - -
17 - -
17-graal - -
17-j9 - -
17-librca - -
21 - -
21-graal - -
21-librca - -
25 - -
25-graal - -
25-librca - -

Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled

Summary: Total: 32 | Passed: 32 | Failed: 0


Updated: 2026-06-05 18:55:36 UTC

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.

1 participant