Bug 1520038

Summary: error: format not a string literal and no format arguments [-Werror=format-security]
Product: [Fedora] Fedora Reporter: Richard W.M. Jones <rjones>
Component: xenAssignee: Michael Young <m.a.young>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 28CC: aoliva, davejohansen, fweimer, jakub, jforbes, jwakely, law, m.a.young, mpolacek, robinlee.sysu
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-06-10 20:48:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
conf.i none

Description Richard W.M. Jones 2017-12-02 11:17:18 UTC
Description of problem:

Please see the log here:

https://koji.fedoraproject.org/koji/taskinfo?taskID=23493193

Version-Release number of selected component (if applicable):

xen-4.9.1-3.fc28

Additional info:

Xen needs to be rebuilt against OCaml 4.06.0 in Rawhide.

Comment 1 Michael Young 2017-12-02 16:30:33 UTC
The error is
tools/kconfig/conf.c:77:3: error: format not a string literal and no format arguments [-Werror=format-security]
   printf(_("aborted!\n\n"));
which looks like a conflict with the rawhide version of gcc and the gettext format. I am assigning this to gcc for investigation.

Comment 2 Florian Weimer 2017-12-02 17:17:27 UTC
Please attach preprocessed sources.  Thanks.

Comment 3 Richard W.M. Jones 2017-12-02 20:40:14 UTC
On my local Rawhide machine this builds OK for me with:

glibc-2.26.9000-28.fc28.x86_64
gcc-7.2.1-4.fc28.x86_64
binutils-2.29.1-5.fc28.x86_64
gettext-0.19.8.1-11.fc27.x86_64

I'm still upgrading packages in the hope of reproducing the
Koji result ...

Comment 4 Richard W.M. Jones 2017-12-02 22:05:38 UTC
Created attachment 1362108 [details]
conf.i

$ gcc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -Wp,-MD,tools/kconfig/.conf.o.d    -D_GNU_SOURCE -D_DEFAULT_SOURCE  -DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1 -DLOCALE -DKBUILD_NO_NLS  -c -o tools/kconfig/conf.o tools/kconfig/conf.c -save-temps
gcc: warning: -pipe ignored because -save-temps specified
tools/kconfig/conf.c: In function ‘check_stdin’:
tools/kconfig/conf.c:77:3: error: format not a string literal and no format arguments [-Werror=format-security]
   printf(_("aborted!\n\n"));
   ^~~~~~
tools/kconfig/conf.c:78:3: error: format not a string literal and no format arguments [-Werror=format-security]
   printf(_("Console input/output is redirected. "));
   ^~~~~~
tools/kconfig/conf.c:79:3: error: format not a string literal and no format arguments [-Werror=format-security]
   printf(_("Run 'make oldconfig' to update configuration.\n\n"));
   ^~~~~~
tools/kconfig/conf.c: In function ‘conf_askvalue’:
tools/kconfig/conf.c:89:3: error: format not a string literal and no format arguments [-Werror=format-security]
   printf(_("(NEW) "));
   ^~~~~~
tools/kconfig/conf.c: In function ‘conf_choice’:
tools/kconfig/conf.c:290:5: error: format not a string literal and no format arguments [-Werror=format-security]
     printf(_(" (NEW)"));
     ^~~~~~
tools/kconfig/conf.c: In function ‘check_conf’:
tools/kconfig/conf.c:438:6: error: format not a string literal and no format arguments [-Werror=format-security]
      printf(_("*\n* Restart config...\n*\n"));
      ^~~~~~
tools/kconfig/conf.c: In function ‘main’:
tools/kconfig/conf.c:640:6: error: format not a string literal and no format arguments [-Werror=format-security]
      _("\n*** The configuration requires explicit update.\n\n"));
      ^~~~~~~
tools/kconfig/conf.c:693:17: error: format not a string literal and no format arguments [-Werror=format-security]
    fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
                 ^
tools/kconfig/conf.c:697:17: error: format not a string literal and no format arguments [-Werror=format-security]
    fprintf(stderr, _("\n*** Error during update of the configuration.\n\n"));
                 ^
tools/kconfig/conf.c:708:17: error: format not a string literal and no format arguments [-Werror=format-security]
    fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
                 ^
cc1: some warnings being treated as errors

Comment 5 Richard W.M. Jones 2017-12-02 22:07:34 UTC
If we take a particular function where this happens, in the
preprocessed output the function is:

  static void check_stdin(void)
  {
   if (!valid_stdin) {
    printf(gettext("aborted!\n\n"));
    printf(gettext("Console input/output is redirected. "));
    printf(gettext("Run 'make oldconfig' to update configuration.\n\n"));
    exit(1);
   }
  }

The only previous mention of "gettext" in the same preprocessed output is:

  static inline const char *gettext(const char *txt) { return txt; }

Comment 6 Jakub Jelinek 2017-12-22 09:40:28 UTC
Clearly a bug in the package.  You are trying to emulate what gettext does, but not properly:

tools/kconfig/lkc.h has:

static inline const char *gettext(const char *txt) { return txt; }
static inline void textdomain(const char *domainname) {}
static inline void bindtextdomain(const char *name, const char *dir) {}
static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; }

If you don't want these warnings, that is not sufficient, either you need to
#define gettext(str) str
or need to use __attribute__ ((__format_arg__ (1))) on the gettext inline, so that the compiler knows it is a pass-through for format strings.
The -Wformat warnings are done early, before any inlining etc. (and after all, e.g. at -O0 there is no inlining anyway except for always_inline).

Comment 7 Fedora End Of Life 2018-02-20 15:35:57 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 28 development cycle.
Changing version to '28'.

Comment 8 Michael Young 2018-06-10 20:48:22 UTC
This problem seems to have gone away (I am not entirely sure why but I am guessing something at the gcc end) so I am closing this bug.