abseil / abseil/abseil-cpp

FormatTime() has regressed in release LTS 20210324.2, for cross compiler (works fine in LTS 20190808)

Open
#1,042 7 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
18.1k
Forks
3.2k
Avg merge
20h 36m
Merged PRs (30d)
1

Description

**Describe the bug**
We are using this library with a purpose built `GCC v7.5-2019.12` cross-compiler targeting ARM Cortex-A15 or Cortex-A9 based upon this software release from Linaro http://releases.linaro.org/components/toolchain/gcc-linaro/7.5-2019.12.

With this cross-compiler the `FormatTime()` API *works fine as expected* in `abseil release LTS 20190808`, but it is **broken** in latest `release LTS 20210324.2`.

**Steps to reproduce the bug**

Build and run this `google-test` with the above cross-compiler

```
#include

#include
#include

#include "absl/time/clock.h"
#include "absl/time/time.h"

TEST(TimeUtilTests, FormatTime) {
for (const auto& [epoch_ns, ts_str] : std::unordered_map({
{1634058342371043590, "2021-10-12T17:05:42"},
{1634058340564981005, "2021-10-12T17:05:40"},
})) {
EXPECT_EQ(absl::FormatTime("%Y-%m-%dT%H:%M:%S", absl::FromUnixNanos(epoch_ns), absl::UTCTimeZone()),
ts_str);
}
}
```
With latest `release LTS 20210324.2` this test **fails**:
```
CFS:default@S001T1190406421(B10:bn) [/tmp]$ ./time_util_test
Running main() from /home/yatish/work/clients/releasedevel/tarana3/cpu/filesystem/grpc/third_party/googletest/googletest/src/gtest_main.cc
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from TimeUtilTests
[ RUN ] TimeUtilTests.FormatTime
util/time_util_test.cpp:14: Failure
Expected equality of these values:
absl::FormatTime("%Y-%m-%dT%H:%M:%S", absl::FromUnixNanos(epoch_ns), absl::UTCTimeZone())
Which is: "2021-10-12T1\0:14:56"
ts_str
Which is: "2021-10-12T17:14:56"
util/time_util_test.cpp:14: Failure
Expected equality of these values:
absl::FormatTime("%Y-%m-%dT%H:%M:%S", absl::FromUnixNanos(epoch_ns), absl::UTCTimeZone())
Which is: "2021-10-12T1\0:05:57"
ts_str
Which is: "2021-10-12T17:05:57"
[ FAILED ] TimeUtilTests.FormatTime (11 ms)
[----------] 1 test from TimeUtilTests (11 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (15 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] TimeUtilTests.FormatTime
```
![image](https://user-images.githubusercontent.com/2176409/137173428-9353c486-97ed-4af4-828c-ee5aa63fbe94.png)

Note the `\0`s in the output, which is why the output string of `FormatTime()` does not match with what is expected.

*This test works fine with `abseil release LTS 20190808`, from which we're trying to upgrade.*

*Also, this is not a regression with gcc/clang on x86, both these releases work fine on it.*

**What version of Abseil are you using?**
LTS 20210324.2

**What operating system and version are you using**
Linux on ARM Cortex-A15 or Cortex-A9

**What compiler and version are you using?**
purpose built `GCC v7.5-2019.12` targeting ARM Cortex-A15 or Cortex-A9 based upon this software release from Linaro http://releases.linaro.org/components/toolchain/gcc-linaro/7.5-2019.12.

**What build system are you using?**
```
$ bazel --version
bazel 4.2.1
```
**Additional context**
None

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.