Project

General

Profile

Actions

Bug #62615

open

GCC 11 with -Warray-bounds has multiple warnings

Added by Kellen Renshaw 8 months ago. Updated 4 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
build
Target version:
-
% Done:

0%

Source:
Community (user)
Tags:
Backport:
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):

Description

Ceph uses a forked implementation of the Abseil (https://github.com/abseil/abseil-cpp/tree/master) library for btrees that was committed in commit https://github.com/ceph/ceph/commit/73f2d70fc8bdbb4a963483ded0487dd744def215 in 2019.

This implementation is causing warnings with -Warray-bounds on GCC 11.4.0-1ubuntu1~22.04 and possibly other platforms.

Example:
cd /home/user/ceph-17.2.6/obj-x86_64-linux-gnu/src && /usr/bin/c++ -DBOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION -DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT -DHAVE_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE -D__CEPH__ -D__STDC_FORMAT_MACROS -D__linux__ -I/home/user/ceph-17.2.6/obj-x86_64-linux-gnu/src/include -I/home/user/ceph-17.2.6/src -isystem /home/user/ceph-17.2.6/obj-x86_64-linux-gnu/include -isystem /home/user/ceph-17.2.6/src/xxHash -isystem /home/user/ceph-17.2.6/src/rapidjson/include -isystem /home/user/ceph-17.2.6/src/fmt/include -g -O2 -ffile-prefix-map=/home/user/ceph-17.2.6=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -O2 -g -DNDEBUG -fPIC -U_FORTIFY_SOURCE -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -Wall -fno-strict-aliasing -fsigned-char -Wtype-limits -Wignored-qualifiers -Wpointer-arith -Werror=format-security -Winit-self -Wno-unknown-pragmas -Wnon-virtual-dtor -Wno-ignored-qualifiers -ftemplate-depth-1024 -Wpessimizing-move -Wredundant-move -Wstrict-null-sentinel -Woverloaded-virtual -fno-new-ttp-matching -fstack-protector-strong -fdiagnostics-color=auto -std=c++17 -MD -MT src/CMakeFiles/common-objs.dir/mon/PGMap.cc.o -MF CMakeFiles/common-objs.dir/mon/PGMap.cc.o.d -o CMakeFiles/common-objs.dir/mon/PGMap.cc.o -c /home/user/ceph-17.2.6/src/mon/PGMap.cc
In file included from /home/user/ceph-17.2.6/src/include/btree_map.h:7,
from /home/user/ceph-17.2.6/src/osd/OSDMap.h:34,
from /home/user/ceph-17.2.6/src/mon/PGMap.cc:18:
/home/user/ceph-17.2.6/src/include/cpp-btree/btree.h: In member function ‘btree::internal::btree<Params>::iterator btree::internal::btree<Params>::internal_emplace(btree::internal::btree<Params>::iterator, Args&& ...) [with Args = {const std::pair<const pg_t, ceph_le<unsigned int>*>&}; Params = btree::internal::map_params<pg_t, ceph_le<unsigned int>*, std::less<pg_t>, std::allocator<std::pair<const pg_t, ceph_le<unsigned int>*> >, 256, false>]’:
/home/user/ceph-17.2.6/src/include/cpp-btree/btree.h:515:84: warning: array subscript 32 is outside array bounds of ‘btree::internal::AlignedAlloc<8, std::allocator<std::pair<const pg_t, ceph_le<unsigned int>*> > >::M [32]’ [-Warray-bounds]
515 | btree_node*& mutable_child(int i) { return GetField<&internal_fields::children>()[i]; } |

Another project had similar issues with the -Warray-bounds issuing warnings and resolved them by switching from their forked version to the upstream one.
https://github.com/google/s2geometry/issues/153

I have looked and the upstream Abseil code has undergone fairly significant changes to the btree code.
https://github.com/abseil/abseil-cpp/blob/master/absl/container/internal/btree.h

The original purpose appears to have been to ensure C++-17 compatibility, however, the upstream Abseil library explicitly supports C++-14 and up, including C++-17.
https://github.com/abseil/abseil-cpp/tree/master/CMake#readme

Aside from potentially re-importing and adapting the code, would a better solution be to import the Abseil library as a submodule?

Actions #1

Updated by Casey Bodley 7 months ago

can we investigate the use of system packages for the abseil library?

i see https://launchpad.net/ubuntu/jammy/+package/libabsl-dev for jammy, and there are various matches for abseil-cpp rpms for centos

Actions #2

Updated by Ilya Dryomov 4 months ago

  • Target version deleted (v17.2.7)
Actions

Also available in: Atom PDF