OpenFastPath / ofp

OpenFastPath project
BSD 3-Clause "New" or "Revised" License
349 stars 126 forks source link

__builtin_strncpy offset is out of the bounds #270

Closed terminaldweller closed 3 years ago

terminaldweller commented 3 years ago

I'm trying to build ofp for odp-dpdk based on the instructions here.
I get the error below:

make[1]: Entering directory '/home/vagrant/devi/ofp/scripts/devbuild_ofp_odp_dpdk/odp-dpdk/platform/linux-dpdk'
  CC       odp_buffer.lo
  CC       odp_crypto.lo
  CC       odp_errno.lo
  CC       ../linux-generic/odp_event.lo
  CC       ../linux-generic/odp_hash_crc32c.lo
  CC       ../linux-generic/odp_hash_crc32.lo
  CC       ../linux-generic/odp_ipsec.lo
  CC       odp_init.lo
  CC       ../linux-generic/odp_impl.lo
  CC       ../linux-generic/odp_name_table.lo
  CC       ../linux-generic/odp_ipsec_sad.lo
  CC       ../linux-generic/odp_ipsec_events.lo
  CC       odp_packet_dpdk.lo
  CC       ../linux-generic/odp_libconfig.lo
  CC       odp_packet.lo
  CC       ../linux-generic/odp_hash_crc_gen.lo
  CC       odp_packet_flags.lo
  CC       ../linux-generic/odp_packet_io.lo
  CC       ../linux-generic/odp_pkt_queue.lo
  CC       odp_queue_basic.lo
  CC       odp_pool.lo
  CC       odp_queue_eventdev.lo
  CC       odp_queue_if.lo
  CC       ../linux-generic/odp_queue_lf.lo
  CC       odp_queue_spsc.lo
  CC       ../linux-generic/odp_rwlock.lo
  CC       ../linux-generic/odp_rwlock_recursive.lo
  CC       ../linux-generic/odp_schedule_basic.lo
  CC       odp_schedule_eventdev.lo
  CC       odp_schedule_if.lo
  CC       ../linux-generic/odp_schedule_sp.lo
  CC       odp_shared_memory.lo
  CC       ../linux-generic/odp_sorted_list.lo
  CC       ../linux-generic/odp_spinlock.lo
In file included from /usr/include/string.h:519,
                 from /home/vagrant/devi/ofp/scripts/devbuild_ofp_odp_dpdk/dpdk/install/include/dpdk/rte_memcpy.h:16,
                 from /home/vagrant/devi/ofp/scripts/devbuild_ofp_odp_dpdk/dpdk/install/include/dpdk/rte_mempool.h:51,
                 from /home/vagrant/devi/ofp/scripts/devbuild_ofp_odp_dpdk/dpdk/install/include/dpdk/rte_mbuf.h:38,
                 from ../../platform/linux-dpdk/include/odp_buffer_internal.h:40,
                 from ../../platform/linux-generic/include/odp_timer_internal.h:18,
                 from ../linux-generic/odp_schedule_sp.c:20:
In function ‘strncpy’,
    inlined from ‘schedule_group_create’ at ../linux-generic/odp_schedule_sp.c:746:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ offset [536, 2120] is out of the bounds [0, 8] [-Werror=array-bounds]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../linux-generic/odp_schedule_sp.c: In function ‘schedule_group_create’:
../linux-generic/odp_schedule_sp.c:748:44: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
  748 |     grp_name[ODP_SCHED_GROUP_NAME_LEN - 1] = 0;
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
../linux-generic/odp_schedule_sp.c:98:21: note: at offset 0 to object ‘lock’ with size 8 declared here
   98 |   odp_ticketlock_t  lock;
      |                     ^~~~
../linux-generic/odp_schedule_sp.c:744:17: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
  744 |     grp_name[0] = 0;
      |     ~~~~~~~~~~~~^~~
../linux-generic/odp_schedule_sp.c:98:21: note: at offset 0 to object ‘lock’ with size 8 declared here
   98 |   odp_ticketlock_t  lock;
      |                     ^~~~
In file included from ../../platform/linux-generic/include/odp_ring_u32_internal.h:19,
                 from ../linux-generic/odp_schedule_basic.c:25:
../linux-generic/odp_schedule_basic.c: In function ‘schedule_term_global’:
../../platform/linux-generic/include/odp_ring_internal.h:133:20: error: array subscript ‘<unknown>’ is outside the bounds of an interior zero-length array ‘uint32_t[0]’ {aka ‘unsigned int[]’} [-Werror=zero-le
bounds]
  133 |  *data = ring->data[new_head & mask];
      |          ~~~~~~~~~~^~~~~~~~~~~~~~~~~
../../platform/linux-generic/include/odp_ring_internal.h:48:11: note: while referencing ‘data’
   48 |  uint32_t data[0];
      |           ^~~~
  CC       ../linux-generic/odp_spinlock_recursive.lo
  CC       ../linux-generic/odp_system_info.lo
In file included from ../../platform/linux-generic/include/odp_ring_u32_internal.h:19,
                 from ../linux-generic/odp_schedule_sp.c:19:
../linux-generic/odp_schedule_sp.c: In function ‘sched_queue’:
../../platform/linux-generic/include/odp_ring_internal.h:207:12: error: array subscript 2047 is outside the bounds of an interior zero-length array ‘uint32_t[0]’ {aka ‘unsigned int[]’} [-Werror=zero-length-bou
  207 |  ring->data[new_head & mask] = data;
      |  ~~~~~~~~~~^~~~~~~~~~~~~~~~~
../../platform/linux-generic/include/odp_ring_internal.h:48:11: note: while referencing ‘data’
   48 |  uint32_t data[0];
      |           ^~~~
  CC       ../linux-generic/odp_pcapng.lo
  CC       odp_thread.lo
  CC       ../linux-generic/odp_thrmask.lo
  CC       odp_time.lo
  CC       odp_timer.lo
  CC       ../linux-generic/odp_traffic_mngr.lo
  CC       ../linux-generic/odp_timer_wheel.lo
../linux-generic/odp_schedule_sp.c: In function ‘pktio_start’:
../../platform/linux-generic/include/odp_ring_internal.h:207:12: error: array subscript 2047 is outside the bounds of an interior zero-length array ‘uint32_t[0]’ {aka ‘unsigned int[]’} [-Werror=zero-length-bou
  207 |  ring->data[new_head & mask] = data;
      |  ~~~~~~~~~~^~~~~~~~~~~~~~~~~
../../platform/linux-generic/include/odp_ring_internal.h:48:11: note: while referencing ‘data’
   48 |  uint32_t data[0];
      |           ^~~~
  CC       ../linux-generic/odp_version.lo
  CC       ../linux-generic/odp_weak.lo
../linux-generic/odp_schedule_basic.c: In function ‘schedule_pktio_start’:
  CC       ../linux-generic/odp_random_openssl.lo
../../platform/linux-generic/include/odp_ring_internal.h:207:12: error: array subscript ‘<unknown>’ is outside the bounds of an interior zero-length array ‘uint32_t[0]’ {aka ‘unsigned int[]’} [-Werror=zero-le
bounds]
  207 |  ring->data[new_head & mask] = data;
      |  ~~~~~~~~~~^~~~~~~~~~~~~~~~~
../../platform/linux-generic/include/odp_ring_internal.h:48:11: note: while referencing ‘data’
   48 |  uint32_t data[0];
      |           ^~~~
../linux-generic/odp_schedule_basic.c: In function ‘schedule_sched_queue’:                                                                                                                                   [8/1809
../linux-generic/odp_schedule_sp.c: In function ‘schedule_multi’:
../../platform/linux-generic/include/odp_ring_internal.h:207:12: error: array subscript 2047 is outside the bounds of an interior zero-length array ‘uint32_t[0]’ {aka ‘unsigned int[]’} [-Werror=zero-length-bou
  207 |  ring->data[new_head & mask] = data;
      |  ~~~~~~~~~~^~~~~~~~~~~~~~~~~
../../platform/linux-generic/include/odp_ring_internal.h:48:11: note: while referencing ‘data’
   48 |  uint32_t data[0];
      |           ^~~~
../../platform/linux-generic/include/odp_ring_internal.h:133:20: error: array subscript 2047 is outside the bounds of an interior zero-length array ‘uint32_t[0]’ {aka ‘unsigned int[]’} [-Werror=zero-length-bou
  133 |  *data = ring->data[new_head & mask];
      |          ~~~~~~~~~~^~~~~~~~~~~~~~~~~
../../platform/linux-generic/include/odp_ring_internal.h:48:11: note: while referencing ‘data’
   48 |  uint32_t data[0];
      |           ^~~~
../../platform/linux-generic/include/odp_ring_internal.h:207:12: error: array subscript 2047 is outside the bounds of an interior zero-length array ‘uint32_t[0]’ {aka ‘unsigned int[]’} [-Werror=zero-length-bou
  207 |  ring->data[new_head & mask] = data;
      |  ~~~~~~~~~~^~~~~~~~~~~~~~~~~
../../platform/linux-generic/include/odp_ring_internal.h:48:11: note: while referencing ‘data’
   48 |  uint32_t data[0];
      |           ^~~~
../../platform/linux-generic/include/odp_ring_internal.h:207:12: error: array subscript ‘<unknown>’ is outside the bounds of an interior zero-length array ‘uint32_t[0]’ {aka ‘unsigned int[]’} [-Werror=zero-le
bounds]
  207 |  ring->data[new_head & mask] = data;
      |  ~~~~~~~~~~^~~~~~~~~~~~~~~~~
../../platform/linux-generic/include/odp_ring_internal.h:48:11: note: while referencing ‘data’
   48 |  uint32_t data[0];
      |           ^~~~
cc1: all warnings being treated as errors
../linux-generic/odp_schedule_basic.c: In function ‘do_schedule’:
../../platform/linux-generic/include/odp_ring_internal.h:133:20: error: array subscript ‘<unknown>’ is outside the bounds of an interior zero-length array ‘uint32_t[0]’ {aka ‘unsigned int[]’} [-Werror=zero-le
bounds]
  133 |  *data = ring->data[new_head & mask];
      |          ~~~~~~~~~~^~~~~~~~~~~~~~~~~
../../platform/linux-generic/include/odp_ring_internal.h:48:11: note: while referencing ‘data’
   48 |  uint32_t data[0];
      |           ^~~~
../../platform/linux-generic/include/odp_ring_internal.h:207:12: error: array subscript ‘<unknown>’ is outside the bounds of an interior zero-length array ‘uint32_t[0]’ {aka ‘unsigned int[]’} [-Werror=zero-le
bounds]
  207 |  ring->data[new_head & mask] = data;
      |  ~~~~~~~~~~^~~~~~~~~~~~~~~~~
../../platform/linux-generic/include/odp_ring_internal.h:48:11: note: while referencing ‘data’
   48 |  uint32_t data[0];
      |           ^~~~
../../platform/linux-generic/include/odp_ring_internal.h:207:12: error: array subscript ‘<unknown>’ is outside the bounds of an interior zero-length array ‘uint32_t[0]’ {aka ‘unsigned int[]’} [-Werror=zero-le
bounds]
  207 |  ring->data[new_head & mask] = data;
      |  ~~~~~~~~~~^~~~~~~~~~~~~~~~~
../../platform/linux-generic/include/odp_ring_internal.h:48:11: note: while referencing ‘data’
   48 |  uint32_t data[0];
      |           ^~~~
../../platform/linux-generic/include/odp_ring_internal.h:207:12: error: array subscript ‘<unknown>’ is outside the bounds of an interior zero-length array ‘uint32_t[0]’ {aka ‘unsigned int[]’} [-Werror=zero-le
bounds]
  207 |  ring->data[new_head & mask] = data;
      |  ~~~~~~~~~~^~~~~~~~~~~~~~~~~
../../platform/linux-generic/include/odp_ring_internal.h:48:11: note: while referencing ‘data’
   48 |  uint32_t data[0];
      |           ^~~~
make[1]: *** [Makefile:1482: ../linux-generic/odp_schedule_sp.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
cc1: all warnings being treated as errors
make[1]: *** [Makefile:1482: ../linux-generic/odp_schedule_basic.lo] Error 1
make[1]: Leaving directory '/home/vagrant/devi/ofp/scripts/devbuild_ofp_odp_dpdk/odp-dpdk/platform/linux-dpdk'
make: *** [Makefile:553: install-recursive] Error 1

I'm on ubuntu 20.10.
here's the output for gcc -v:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 10.2.0-13ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/
lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie -
-with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 -
-enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-JvwpWM/gcc-10-10.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-JvwpWM/gcc-10-10.2.0/debian/tmp-gcn/usr,hsa --without-cu
da-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (Ubuntu 10.2.0-13ubuntu1)
bogdanPricope commented 3 years ago

First, this is an ODP build problem not OFP. Either your Linux version is too new or your ODP version is too old or both... You may ask this guys ( https://github.com/OpenDataPlane/odp ) about supported GCC version.

I am building a version of this with Ubuntu 18.04.3 LTS.

terminaldweller commented 3 years ago

ubuntu 20.10 seems to be too new indeed. thanks.