• Status New
  • Percent Complete
    0%
  • Task Type Bug Report
  • Category Packages
  • Assigned To No-one
  • Operating System pentium4
  • Severity Low
  • Priority Medium
  • Reported Version
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: Arch Linux 32
Opened by Andreas Baumann - 08.07.2022
Last edited by Andreas Baumann - 08.07.2022

FS#275 - [protobuf] breaks heavily on 32-bit

/build/protobuf/src/protobuf-21.2/src/google/protobuf/repeated_field.h: In instantiation of ‘constexpr int google::protobuf::internal::RepeatedFieldLowerClampLimit() [with T = long long int; int kRepHeaderSize = 4]’:

/data/work/arch32/protobuf/src/protobuf-21.2/src/google/protobuf/repeated_field.h:81:27: note: the comparison reduces to ‘(8 ⇐ 4)’

Admin
Andreas Baumann commented on 08.07.2022 17:27

/data/work/arch32/protobuf/src/protobuf-21.2/src/google/protobuf/extension_set_unittest.cc:881:3: required from here

TEST_REPEATED_EXTENSIONS_SPACE_USED(double, double, 112);

/data/work/arch32/protobuf/src/protobuf-21.2/src/google/protobuf/extension_set_unittest.cc:873:3: required from here

TEST_REPEATED_EXTENSIONS_SPACE_USED(uint64, uint64_t, 104);

/data/work/arch32/protobuf/src/protobuf-21.2/src/google/protobuf/extension_set_unittest.cc:871:3: required from here

TEST_REPEATED_EXTENSIONS_SPACE_USED(int64, int64_t, 102);

So, this is a mixup with int64 definitions on 32-bit machines?

Admin
Andreas Baumann commented on 08.07.2022 17:31

Or the header size is not computed correctly..

Admin
Andreas Baumann commented on 08.07.2022 17:36

Mmh. In the worst case this is a compiler thing..

Admin
Andreas Baumann commented on 08.12.2022 11:48

Tried all versions between 21.1 and 21.10, all of them fail the same way, so this
is likely a compiler issue..

Admin
Andreas Baumann commented on 08.12.2022 14:12

tried clang, no success.. it insist on using GNU ld and fails with tons of linker
errors..

Admin
Andreas Baumann commented on 10.12.2022 07:48

Building a gcc11 fails in:

/build/gcc11/src/gcc/libiberty/fibheap.c: In function ‘fibheap_replace_key_data’:
/build/gcc11/src/gcc/libiberty/fibheap.c:38:25: error: ‘LONG_MIN’ undeclared (first use in this function)
   38 | #define FIBHEAPKEY_MIN  LONG_MIN
      |                         ^~~~~~~~
/build/gcc11/src/gcc/libiberty/fibheap.c:220:30: note: in expansion of macro ‘FIBHEAPKEY_MIN’
  220 |   if (okey == key && okey != FIBHEAPKEY_MIN)
      |                              ^~~~~~~~~~~~~~
/build/gcc11/src/gcc/libiberty/fibheap.c:36:1: note: ‘LONG_MIN’ is defined in header ‘<limits.h>’; did you forget to ‘#include <limits.h>’?
   35 | #include "fibheap.h"
  +++ |+#include <limits.h>

So it might be easier to try to fix protobuf for gcc 12 than to try to
fix the old compiler to build on newer toolchains.

There is also the possibility that CFLAGS play bad tricks during toolchain
building..

TasosSah commented on 11.02.2023 21:07

I had a look into this.

This happens because the TEST_REPEATED_EXTENSIONS_SPACE_USED() macro calls

RepeatedFieldLowerClampLimit<cpptype, sizeof(void*)>())

with sometimes sizeof(cpptype) > sizeof(void*), such as int64_t on 32 bit architectures, thus the 8 < = 4 fail.

This was introduced by commit ab4585a6956675ce14a1cba5d321fde980bbf12b, which replaced

constexpr int kRepeatedFieldLowerClampLimit = 4;

with the new templated function RepeatedFieldLowerClampLimit() which has the problematic assert:

static_assert(sizeof(T) <= kRepHeaderSize, "");

I got it to build by replacing that function in src/google/protobuf/repeated_field.h with just

template <typename T, int kRepHeaderSize>
constexpr int RepeatedFieldLowerClampLimit() {
  return 4;
}

as it used to be before.

8 tests fail on pentium4, however I don't know if they failed before or if they are caused by this change now. I haven't touched i686 yet.

[  PASSED  ] 2366 tests.
[  SKIPPED ] 1 test, listed below:
[  SKIPPED ] ArenaTest.SpaceReusePoisonsAndUnpoisonsMemory
[  FAILED  ] 8 tests, listed below:
[  FAILED  ] AnyTest.TestPackFromSerializationExceedsSizeLimit
[  FAILED  ] ArenaTest.SpaceAllocated_and_Used
[  FAILED  ] ArenaTest.BlockSizeSmallerThanAllocation
[  FAILED  ] GeneratedMessageTest.MoreStringSize
[  FAILED  ] IoTest.LargeOutput
[  FAILED  ] RepeatedField.NaturalGrowthOnArenasReuseBlocks
[  FAILED  ] RepeatedField.ReserveLowerClamp
[  FAILED  ] RepeatedPtrField.NaturalGrowthOnArenasReuseBlocks

 8 FAILED TESTS
make[3]: *** [CMakeFiles/check.dir/build.make:71: CMakeFiles/check] Error 1
make[2]: *** [CMakeFiles/Makefile2:373: CMakeFiles/check.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:380: CMakeFiles/check.dir/rule] Error 2
make: *** [Makefile:309: check] Error 2
TasosSah commented on 13.02.2023 18:40

Turns out this was fixed upstream, https://github.com/protocolbuffers/protobuf/pull/10589

Unfortunately, the fix relies on C++14 (while the current release is built as C++11), so a custom patch will need to be applied until it makes it into the next release.

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing