[libc] Overflow error on riscv32 in strfrom functions
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Looks like https://github.com/llvm/llvm-project/pull/166517 is breaking libc-riscv32-qemu-yocto-fullbuild-dbg build due to failing overflow test for strfrom.
https://lab.llvm.org/buildbot/#/changes/58668
```
int result = func(buff, sizeof(buff), "%.2147483647f", 1.0f);
EXPECT_LT(result, 0);
ASSERT_ERRNO_FAILURE();
```
```
[ RUN ] LlvmLibcStrfromdTest.CharsWrittenOverflow
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/src/stdlib/StrfromTest.h:493: FAILURE
Expected: result
Which is: 0
To be less than: 0
Which is: 0
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/src/stdlib/StrfromTest.h:494: FAILURE
Expected: 0
Which is: 0
To be not equal to: static_cast(libc_errno)
Which is: 0
[ FAILED ] LlvmLibcStrfromdTest.CharsWrittenOverflow
Ran 8 tests. PASS: 7 FAIL: 1
```
At first glance it seem like there is some kind of overflow in internal::strfromfloat_convert on 32bit archs because the other overflow test case is passing for snprintf. Interestingly, it passes on all other buildbots, including libc-arm32-qemu-debian-dbg.
This issue likely wasn't introduced by https://github.com/llvm/llvm-project/pull/166517 and was probably already present.
Contributor guide
Research direction
Start with libc/test/src/stdlib/StrfromTest.h around the LlvmLibcStrfromdTest.CharsWrittenOverflow test and reproduce the failure in the libc-riscv32-qemu-yocto-fullbuild-dbg configuration. Trace the reported internal::strfromfloat_convert path and compare it with the passing snprintf overflow case; done means the strfrom overflow test reports an error on riscv32 without regressing the other cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- operating-systems, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100