Commit 5cba6e5
authored
fix(cpp): fix the type error (#2961)
<!--
**Thanks for contributing to Apache Fory™.**
**If this is your first time opening a PR on fory, you can refer to
[CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).**
Contribution Checklist
- The **Apache Fory™** community has requirements on the naming of pr
titles. You can also find instructions in
[CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).
- Apache Fory™ has a strong focus on performance. If the PR you submit
will have an impact on performance, please benchmark it first and
provide the benchmark result here.
-->
## Why?
<!-- Describe the purpose of this PR. -->
Fix the abnormal data type judgment in CPP buffer.h
(std::numeric_limits<int>::max()).
## What does this PR do?
<!-- Describe the details of this PR. -->
run
```bash
cd benchmarks/cpp_benchmark
./profile.sh --duration 10 --filter BM_Fory_Struct_Serialize
```
Got the following error:
```
=== Fory C++ Benchmark Profiler ===
Filter: BM_Fory_Struct_Serialize
Duration: 10s
Output: profile_output
Profiling with samply...
Running: samply record ./fory_benchmark --benchmark_min_time=10s --benchmark_filter=BM_Fory_Struct_Serialize
Unable to determine clock rate from sysctl: hw.cpufrequency: No such file or directory
This does not affect benchmark measurements, only the metadata output.
***WARNING*** Failed to set thread affinity. Estimated CPU frequency may be incorrect.
2025-12-02T16:23:03+08:00
Running ./fory_benchmark
Run on (10 X 24 MHz CPU s)
CPU Caches:
L1 Data 64 KiB
L1 Instruction 128 KiB
L2 Unified 4096 KiB (x10)
Load Average: 2.09, 2.23, 2.36
[2025-12-02 16:23:11,944] FATAL fory/cpp/fory/util/buffer.h:86: Check failed: writer_index < std::numeric_limits<int>::max() Buffer overflow writer_index2147483646 diff 1
*** StackTrace Information ***
fory::GetCallTrace()
fory::ForyLog::~ForyLog()
fory::serialization::Serializer<>::write()
fory::serialization::Fory::serialize_impl<>()
BM_Fory_Struct_Serialize()
benchmark::internal::BenchmarkInstance::Run()
benchmark::internal::(anonymous namespace)::RunInThread()
benchmark::internal::BenchmarkRunner::DoNIterations()
benchmark::internal::BenchmarkRunner::DoOneRepetition()
benchmark::RunSpecifiedBenchmarks()
benchmark::RunSpecifiedBenchmarks()
main
start
```
In `buffer.h`, `writer_index_` and `reader_index_` are of the `uint32_t`
type.
Signed-off-by: Liangliang Sui <[email protected]>1 parent 8181e14 commit 5cba6e5
1 file changed
+6
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
86 | | - | |
| 85 | + | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
100 | | - | |
| 99 | + | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
0 commit comments