Array subscript 0 is outside array bounds of 'uint32_t[0:] warnings during firmware compilation

Basic Information:

Printer Model: Sovol SV06 Plus with SKR 1.4 non-turbo MCU
MCU / Printerboard: BTT SKR 1.4 non-turbo
klippy.log: didn’t get that far

I was trying to compile Klipper for an SKR 1.4 (LPC 1768). When I try to compile the firmware as suggested online I get errors about an array out of bounds. A klipper.bin file is still created, but I did not try to use it.

[*] Enable extra low-level configuration options
    Micro-controller Architecture (LPC176x (Smoothieboard))  --->
    Processor model (lpc1768 (100 MHz))  --->
    Bootloader offset (16KiB bootloader (Smoothieware bootloader))  --->
    Communication interface (USB)  --->
    USB ids  --->
()  GPIO pins to set at micro-controller startup

Compilation console output:

wayne@BasementFoldingDell:~/klipper$ make clean
wayne@BasementFoldingDell:~/klipper$ make
  Creating symbolic link out/board
  Building out/autoconf.h
  Compiling out/src/sched.o
  Compiling out/src/command.o
  Compiling out/src/basecmd.o
  Compiling out/src/debugcmds.o
  Compiling out/src/initial_pins.o
  Compiling out/src/gpiocmds.o
  Compiling out/src/stepper.o
  Compiling out/src/endstop.o
  Compiling out/src/trsync.o
  Compiling out/src/adccmds.o
  Compiling out/src/spicmds.o
  Compiling out/src/i2ccmds.o
  Compiling out/src/pwmcmds.o
  Compiling out/src/buttons.o
  Compiling out/src/tmcuart.o
  Compiling out/src/neopixel.o
  Compiling out/src/pulse_counter.o
  Compiling out/src/lcd_st7920.o
  Compiling out/src/lcd_hd44780.o
  Compiling out/src/spi_software.o
  Compiling out/src/i2c_software.o
  Compiling out/src/sensor_lis2dw.o
  Compiling out/src/thermocouple.o
  Compiling out/src/sensor_adxl345.o
  Compiling out/src/sensor_angle.o
  Compiling out/src/sensor_mpu9250.o
  Compiling out/src/lpc176x/main.o
  Compiling out/src/lpc176x/gpio.o
  Compiling out/src/generic/armcm_boot.o
  Compiling out/src/generic/armcm_irq.o
  Compiling out/src/generic/armcm_timer.o
  Compiling out/src/generic/armcm_reset.o
In function 'canboot_reset',
    inlined from 'try_request_canboot' at src/generic/armcm_reset.c:41:5:
src/generic/armcm_reset.c:24:49: warning: array subscript 0 is outside array bounds of 'uint32_t[0:]' [-Warray-bounds]
   24 |     uint64_t *boot_sig = (uint64_t *)(bl_vectors[1] - 9);
      |                                       ~~~~~~~~~~^~~
In function 'canboot_reset',
    inlined from 'command_reset' at src/generic/armcm_reset.c:47:5:
src/generic/armcm_reset.c:24:49: warning: array subscript 0 is outside array bounds of 'uint32_t[0:]' [-Warray-bounds]
   24 |     uint64_t *boot_sig = (uint64_t *)(bl_vectors[1] - 9);
      |                                       ~~~~~~~~~~^~~
  Compiling out/src/generic/crc16_ccitt.o
  Compiling out/src/../lib/lpc176x/device/system_LPC17xx.o
  Compiling out/src/lpc176x/adc.o
  Compiling out/src/lpc176x/i2c.o
  Compiling out/src/lpc176x/spi.o
  Compiling out/src/lpc176x/usbserial.o
  Compiling out/src/lpc176x/chipid.o
  Compiling out/src/generic/usb_cdc.o
  Compiling out/src/lpc176x/hard_pwm.o
  Building out/compile_time_request.o
Version: v0.12.0-55-gb5025580
  Preprocessing out/src/generic/armcm_link.ld
  Linking out/klipper.elf
lto-wrapper: warning: using serial compilation of 5 LTRANS jobs
lto-wrapper: note: see the '-flto' option documentation for more information
  Creating bin file out/klipper.bin

This was on a fresh install of Debian 12 (more on that later) and KIAUH/Klipper. I did some playing around with options. I could create binaries for rp2040 targets without issue. I could create a binary for LPC 1768 target without those array errors if I changed (against advice) the bootloader from ‘16 KiB Smoothieware’ to ‘none’.

I have another system running Ubuntu 22.04. I updated KIAUH
and Klipper on that system to the latest versions and compiled Klipper for my LPC 1768 target with 16 KiB bootloader without any array oob problems. I used this binary for my printer and it is working fine.

I did some looking around online and found a number of people on other software projects talking about array out of bounds errors when compiling with gcc 12. The Debian machines (I tried two) both run gcc 12.2. The Ubuntu system runs gcc 11.4. As stated earlier, this problem only manifests under certain conditions (in my case when enabling the Smoothieware 16 KiB bootloader option).

I’m running a LPC board myself and also noticed this warning.

In the end it is a warning. This means that there is a theoretical possibility for an OOB condition. It does not mean that it will ever happen and if, likely, Klipper will crash hard.

Personally, I have not noticed problems so far.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.