abseil / abseil/abseil-cpp

NotificationTest.SanityTest fails when -D_TIME_BITS=64 in effect on 32bit

Abierto
#1,547 2 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
C++
Estrellas
18.1k
Forks
3.2k
Merge medio
20 h 36 min
PR fusionados (30 d)
1

Descripción

### Describe the issue

When compiling with CXXFLAGS="-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64",
NotificationTest.SanityTest, PerThreadSemTest.Timeouts fails in obscure way:

```
2023-10-09 16:38:37 [ RUN ] NotificationTest.SanityTest
2023-10-09 16:38:37 ../absl/synchronization/notification_test.cc:83: Failure
2023-10-09 16:38:37 Expected: (delay - slop) <= (elapsed), actual: 49.8ms vs 6.9us
2023-10-09 16:38:37 WaitForNotificationWithTimeout returned 49.9931ms early (with 200us slop), start time was 2023-10-09T16:38:37.439297545+09:00
2023-10-09 16:38:37 ../absl/synchronization/notification_test.cc:83: Failure
2023-10-09 16:38:37 Expected: (delay - slop) <= (elapsed), actual: 49.8ms vs 6.9us
2023-10-09 16:38:37 WaitForNotificationWithTimeout returned 49.9931ms early (with 200us slop), start time was 2023-10-09T16:38:37.443426343+09:00
2023-10-09 16:38:37 [ FAILED ] NotificationTest.SanityTest (4 ms)

2023-10-09 16:38:41 [ RUN ] PerThreadSemTest.Timeouts
2023-10-09 16:38:41 ../absl/synchronization/internal/per_thread_sem_test.cc:163: Failure
2023-10-09 16:38:41 Expected: (delay - slop) <= (elapsed), actual: 49ms vs 7.765us
2023-10-09 16:38:41 Wait returned 49.992235ms early (with 1ms slop), start time was 2023-10-09T16:38:41.50541995+09:00
2023-10-09 16:38:41 [ FAILED ] PerThreadSemTest.Timeouts (0 ms)
```

### Steps to reproduce the problem

Be sure you're in a 32bit environment.
```
CXXFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m32 -march=i586 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -fcf-protection=none' \
/usr/bin/cmake -S . -B redhat-linux-build -DCMAKE_C_FLAGS_RELEASE:STRING=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE:STRING=-DNDEBUG -DCMAKE_Fortran_FLAGS_RELEASE:STRING=-DNDEBUG -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_INSTALL_DO_STRIP:BOOL=OFF -DCMAKE_INSTALL_PREFIX:PATH=/usr -DINCLUDE_INSTALL_DIR:PATH=/usr/include -DLIB_INSTALL_DIR:PATH=/usr/lib -DSYSCONF_INSTALL_DIR:PATH=/etc -DSHARE_INSTALL_PREFIX:PATH=/usr/share -DBUILD_SHARED_LIBS:BOOL=ON -GNinja -DABSL_USE_EXTERNAL_GOOGLETEST:BOOL=ON -DABSL_FIND_GOOGLETEST:BOOL=ON -DABSL_ENABLE_INSTALL:BOOL=ON -DBUILD_TESTING:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=None -DCMAKE_CXX_STANDARD:STRING=17

/usr/bin/cmake --build redhat-linux-build -j4 --verbose

cd redhat-linux-build
/usr/bin/ctest --output-on-failure --force-new-ctest-process -j4
```

### What version of Abseil are you using?

abseil-cpp-20211102

### What operating system and version are you using?

Rocky Linux 9.2 (Red Hat Enterprise Linux 9.2 compatible)
Linux rocky9.five.ten 5.14.0-162.6.1.el9_1.0.1.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Nov 28 18:44:09 UTC 2022 i686 i686 i386 GNU/Linux

### What compiler and version are you using?

```
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i586-redhat-linux/11/lto-wrapper
Target: i586-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-host-pie --enable-host-bind-now --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.rockylinux.org/ --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-plugin --enable-initfini-array --without-isl --enable-multilib --with-linker-hash-style=gnu --enable-gnu-indirect-function --with-tune=generic --with-arch=i586 --build=i586-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.3.1 20221121 (Red Hat 11.3.1-4) (GCC)

```

### What build system are you using?

```
$ cmake --version
cmake version 3.20.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).
```

### Additional context

The cause was that absl/synchronization/internal/futex.h was not using futex_time64(), but raw futex() with 64bit struct timespec.
Following patch fixed the test in -D_TIME_BITS=64 environment:
```
diff -up ./absl/synchronization/internal/futex.h.t64 ./absl/synchronization/internal/futex.h
--- ./absl/synchronization/internal/futex.h.t64 2021-11-04 00:26:14.000000000 +0900
+++ ./absl/synchronization/internal/futex.h 2023-10-11 22:09:10.080086474 +0900
@@ -82,6 +82,10 @@ namespace synchronization_internal {
#if defined(SYS_futex_time64) && !defined(SYS_futex)
#define SYS_futex SYS_futex_time64
#endif
+#if defined(_TIME_BITS) && _TIME_BITS == 64
+#undef SYS_futex
+#define SYS_futex SYS_futex_time64
+#endif

class FutexImpl {
public:
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.