fix(dart): use getUint32 for correctly encoding u64 value#3592
fix(dart): use getUint32 for correctly encoding u64 value#3592chaokunyang merged 4 commits intoapache:mainfrom
Conversation
|
@chaokunyang |
| int readTaggedUint64() { | ||
| final readIndex = _readerIndex; | ||
| final first = _view.getInt32(readIndex, Endian.little); | ||
| final first = _view.getUint32(readIndex, Endian.little); |
There was a problem hiding this comment.
This fixes Buffer.readTaggedUint64(), but GeneratedReadCursor.readTaggedUint64() in dart/packages/fory/lib/src/codegen/generated_support.dart still reads the first word with getInt32. Generated serializers route tagged uint64 fields through that cursor path, so 0x7fffffff still round-trips there as 9223372036854775807 instead of 2147483647. The generated path needs the same getUint32 change and a regression test.
I missed that, let me add it |
## Why? ## What does this PR do? ## Related issues #3592 ## AI Contribution Checklist - [ ] Substantial AI assistance was used in this PR: `yes` / `no` - [ ] If `yes`, I included a completed [AI Contribution Checklist](https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs) in this PR description and the required `AI Usage Disclosure`. - [ ] If `yes`, my PR description includes the required `ai_review` summary and screenshot evidence of the final clean AI review results from both fresh reviewers on the current PR diff or current HEAD after the latest code changes. ## Does this PR introduce any user-facing change? - [ ] Does this PR introduce any public API change? - [ ] Does this PR introduce any binary protocol compatibility change? ## Benchmark
@chaokunyang |
it seems licenserc doesn't support check dart, could you check it? |
@chaokunyang and for the licenserc issue, we just need to add the |
Why?
getInt32treats the top bit as a sign bit. For large values where that bit is set (0xFFFFFFFE), the number comes back negative. Even though >>> is unsigned shift, it is shifting the already-corrupted signed value, garbage in, garbage out.What does this PR do?
Use
getUint32instead.getUint32has no sign bit, so all 32 bits are treated as magnitude.Related issues
N/A
AI Contribution Checklist
yes/noyes, I included a completed AI Contribution Checklist in this PR description and the requiredAI Usage Disclosure.yes, my PR description includes the requiredai_reviewsummary and screenshot evidence of the final clean AI review results from both fresh reviewers on the current PR diff or current HEAD after the latest code changes.Does this PR introduce any user-facing change?
Benchmark