Bug 45927 - procps: ошибка сборки с GCC 13
Summary: procps: ошибка сборки с GCC 13
Status: NEW
Alias: None
Product: Sisyphus
Classification: Development
Component: procps (show other bugs)
Version: unstable
Hardware: all Linux
: P5 normal
Assignee: Mikhail Efremov
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-21 14:31 MSK by Alexey Sheplyakov
Modified: 2023-10-05 16:02 MSK (History)
6 users (show)

See Also:


Attachments
патч (5.14 KB, patch)
2023-04-21 15:42 MSK, Alexey Sheplyakov
no flags Details | Diff
disable_trunc_error.patch (648 bytes, patch)
2023-04-24 17:58 MSK, Mikhail Efremov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Sheplyakov 2023-04-21 14:31:47 MSK
make[2]: Entering directory '/home/asheplyakov/work/bootstrap/RPM/BUILD/procps-3.3.17-alt7.g37f1060'
gcc -std=gnu99 -DHAVE_CONFIG_H -I.  -include ./config.h -I. -I./include -Wno-unused-result -DLOCALEDIR=\"/usr/share/locale\"  -Iproc -pipe -frecord-gcc-switches -Wall -g -O2 -Werror -c -o top/top.o top/top.c
top/top.c: In function 'keys_window':
top/top.c:4471:55: error: '%s' directive output may be truncated writing up to 127 bytes into a region of size 4 [-Werror=format-truncation=]
 4471 |       snprintf(q->rc.winname, sizeof(q->rc.winname), "%s", name);
      |                                                       ^~
......
 5631 |             if (tmp[0] && tmp[0] != kbd_ESC) win_names(w, tmp);
      |                                                           ~~~
In function 'win_names',
    inlined from 'keys_window' at top/top.c:5631:46:
top/top.c:4471:7: note: 'snprintf' output between 1 and 128 bytes into a destination of size 4
 4471 |       snprintf(q->rc.winname, sizeof(q->rc.winname), "%s", name);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
top/top.c: In function 'keys_window':
top/top.c:4472:49: error: '%s' directive output may be truncated writing up to 127 bytes into a region of size between 0 and 4 [-Werror=format-truncation=]
 4472 |    snprintf(q->grpname, sizeof(q->grpname), "%d:%s", q->winnum, name);
      |                                                 ^~
......
 5631 |             if (tmp[0] && tmp[0] != kbd_ESC) win_names(w, tmp);
      |                                                           ~~~
In function 'win_names',
    inlined from 'keys_window' at top/top.c:5631:46:
top/top.c:4472:4: note: 'snprintf' output between 3 and 140 bytes into a destination of size 6
 4472 |    snprintf(q->grpname, sizeof(q->grpname), "%d:%s", q->winnum, name);
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:1572: top/top.o] Error 1
make[2]: Leaving directory '/home/asheplyakov/work/bootstrap/RPM/BUILD/procps-3.3.17-alt7.g37f1060'
make[1]: *** [Makefile:1908: all-recursive] Error 1
make: *** [Makefile:1077: all] Error 2
error: Bad exit status from /home/asheplyakov/work/bootstrap/tmp/rpm-tmp.86525 (%build)
Comment 1 Alexey Sheplyakov 2023-04-21 14:32:59 MSK
Возможно связано с https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95755 (но это не точно)
Comment 2 Alexey Sheplyakov 2023-04-21 14:56:16 MSK
5628          if (ALTCHKw) {
5629             char tmp[SMLBUFSIZ];
5630             STRLCPY(tmp, ioline(fmtmk(N_fmt(NAME_windows_fmt), w->rc.winname)));          
5631             if (tmp[0] && tmp[0] != kbd_ESC) win_names(w, tmp);                           
5632          } 
5633          break;

$ grep -r -n -E 'define\s+SMLBUFSIZ\b'
top/top.h:139:#define SMLBUFSIZ   128


4467 static void win_names (WIN_t *q, const char *name) {
4468    /* note: sprintf/snprintf results are "undefined" when src==dst,
4469             according to C99 & POSIX.1-2001 (thanks adc) */
4470    if (q->rc.winname != name)
4471       snprintf(q->rc.winname, sizeof(q->rc.winname), "%s", name);
4472    snprintf(q->grpname, sizeof(q->grpname), "%d:%s", q->winnum, name);
4473 } // end: win_names

$ grep -e 'winname' 'top/top.h'

#define WINNAMSIZ  4             /* size of RCW_t winname buf (incl '\0')  */
   char   winname [WINNAMSIZ],    // name for the window, user changeable


На первый взгляд это действительно попытка напечатать до 128 байт в буфер размером 4 байта
Comment 3 Alexey Sheplyakov 2023-04-21 15:42:01 MSK
Created attachment 12996 [details]
патч
Comment 4 Mikhail Efremov 2023-04-24 17:58:13 MSK
Created attachment 13009 [details]
disable_trunc_error.patch

(In reply to Alexey Sheplyakov from comment #2)
> На первый взгляд это действительно попытка напечатать до 128 байт в буфер
> размером 4 байта

Да, похоже апстрим считает, что truncation здесь - это нормально.
Думаю, можно просто выключить -Werror в этом месте. Проверьте, пожалуйста, работает ди такой вариант.
Comment 5 Mikhail Efremov 2023-10-05 16:02:32 MSK
Я не вижу такой ошибки с gcc13. Может проблема возникает только на конкретной архитектуре?