Skip to content

Warnings on the current main branch #108562

Description

@skirpichev

Bug report

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.13.0a0 (main, Aug 28 2023, 13:54:29) [GCC 12.2.0]

A clear and concise description of the bug:

With

$ # Mon Aug 28 13:44:26 MSK 2023
$ wget https://github.com/python/cpython/archive/refs/heads/main.zip
$ unzip -x main.zip
$ cd cpython-main/
$ ./configure -q && make -s

Build is successful, but I see a bunch of warnings:

In function ‘_io_FileIO_close_impl’,
    inlined from ‘_io_FileIO_close’ at ./Modules/_io/clinic/fileio.c.h:34:12:
./Modules/_io/fileio.c:170:9: warning: ‘exc’ may be used uninitialized [-Wmaybe-uninitialized]
  170 |         _PyErr_ChainExceptions1(exc);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Modules/_io/fileio.c: In function ‘_io_FileIO_close’:
./Modules/_io/fileio.c:155:15: note: ‘exc’ was declared here
  155 |     PyObject *exc;
      |               ^~~
Note: Deepfreeze may have added some global objects,
      so run 'make regen-global-objects' if necessary.
In function ‘word_to_string’,
    inlined from ‘coeff_to_string’ at ./Modules/_decimal/libmpdec/io.c:410:13,
    inlined from ‘_mpd_to_string’ at ./Modules/_decimal/libmpdec/io.c:611:18:
./Modules/_decimal/libmpdec/io.c:348:40: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  348 |         if (s == dot) *s++ = '.'; *s++ = '0' + (char)(x / d); x %= d
      |                                   ~~~~~^~~~~~~~~~~~~~~~~~~~~
./Modules/_decimal/libmpdec/io.c:359:14: note: in expansion of macro ‘EXTRACT_DIGIT’
  359 |     case 15: EXTRACT_DIGIT(s, x, 100000000000000ULL, dot);
      |              ^~~~~~~~~~~~~
./Modules/_decimal/libmpdec/io.c:348:40: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  348 |         if (s == dot) *s++ = '.'; *s++ = '0' + (char)(x / d); x %= d
      |                                   ~~~~~^~~~~~~~~~~~~~~~~~~~~
./Modules/_decimal/libmpdec/io.c:360:14: note: in expansion of macro ‘EXTRACT_DIGIT’
  360 |     case 14: EXTRACT_DIGIT(s, x, 10000000000000ULL, dot);
      |              ^~~~~~~~~~~~~
./Modules/_decimal/libmpdec/io.c:348:40: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  348 |         if (s == dot) *s++ = '.'; *s++ = '0' + (char)(x / d); x %= d
      |                                   ~~~~~^~~~~~~~~~~~~~~~~~~~~
./Modules/_decimal/libmpdec/io.c:361:14: note: in expansion of macro ‘EXTRACT_DIGIT’
  361 |     case 13: EXTRACT_DIGIT(s, x, 1000000000000ULL, dot);
      |              ^~~~~~~~~~~~~
[...]

N.B. second type of warnings (expansions of EXTRACT_DIGIT) seems to be related to the gcc-12. The first I've seen on the Debian Buster (with gcc-10 per default).

Linked PRs

Activity

  1. sobolevn commented on Aug 28, 2023

    @sobolevn
    Member

    On macos it produces a different result:

    » ./configure -q && make -s
    Python/optimizer.c:388:9: warning: variable 'reserved' set but not used [-Wunused-but-set-variable]
        int reserved = 0;
            ^
    1 warning generated.
    Note: Deepfreeze may have added some global objects,
          so run 'make regen-global-objects' if necessary.
    ./Modules/readline.c:1257:21: warning: incompatible function pointer types assigning to 'Function *' (aka 'int (*)(const char *, int)') from 'int (void)' [-Wincompatible-function-pointer-types]
        rl_startup_hook = on_startup_hook;
                        ^ ~~~~~~~~~~~~~~~
    ./Modules/readline.c:1259:23: warning: incompatible function pointer types assigning to 'Function *' (aka 'int (*)(const char *, int)') from 'int (void)' [-Wincompatible-function-pointer-types]
        rl_pre_input_hook = on_pre_input_hook;
                          ^ ~~~~~~~~~~~~~~~~~
    2 warnings generated.
    Undefined symbols for architecture arm64:
      "__Py_DECREF_DecRefTotal", referenced from:
          _test_open_code_hook in _testembed.o
          _test_unicode_id_init in _testembed.o
          _Py_DECREF in _testembed.o
      "__Py_NegativeRefcount", referenced from:
          _test_open_code_hook in _testembed.o
          _test_unicode_id_init in _testembed.o
          _Py_DECREF in _testembed.o
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [Programs/_testembed] Error 1
  2. skirpichev commented on Aug 29, 2023

    @skirpichev
    MemberAuthor

    @sobolevn, in my case the build was successful. I did update of the bugreport in case it wasn't clear.

  3. skrah commented on Jan 29, 2024

    @skrah
    Contributor

    The libmpdec warning is a false positive due to -fno-strict-overflow:

    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113664

    libmpdec very much supports strict overflow, so adding -fstrict=overflow to LIBMPDEC_CFLAGS should fix this.

  4. skirpichev commented on Jan 30, 2024

    @skirpichev
    MemberAuthor

    @skrah, maybe I miss something, but with --with-strict-overflow I still see warnings:

    $ ./configure -q --with-strict-overflow && make -s
    In function ‘word_to_string’,
        inlined from ‘coeff_to_string’ at ./Modules/_decimal/libmpdec/io.c:410:13,
        inlined from ‘_mpd_to_string’ at ./Modules/_decimal/libmpdec/io.c:611:18:
    ./Modules/_decimal/libmpdec/io.c:348:40: warning: array subscript 0 is outside array bounds of ‘char[0]’ [-Warray-bounds]
      348 |         if (s == dot) *s++ = '.'; *s++ = '0' + (char)(x / d); x %= d
          |                                   ~~~~~^~~~~~~~~~~~~~~~~~~~~
    ./Modules/_decimal/libmpdec/io.c:355:14: note: in expansion of macro ‘EXTRACT_DIGIT’
      355 |     case 19: EXTRACT_DIGIT(s, x, 1000000000000000000ULL, dot);
          |              ^~~~~~~~~~~~~
    In function ‘word_to_string’,
        inlined from ‘coeff_to_string’ at ./Modules/_decimal/libmpdec/io.c:410:13,
        inlined from ‘_mpd_to_string’ at ./Modules/_decimal/libmpdec/io.c:607:18:
    ./Modules/_decimal/libmpdec/io.c:348:40: warning: array subscript 0 is outside array bounds of ‘char[0]’ [-Warray-bounds]
      348 |         if (s == dot) *s++ = '.'; *s++ = '0' + (char)(x / d); x %= d
          |                                   ~~~~~^~~~~~~~~~~~~~~~~~~~~
    ./Modules/_decimal/libmpdec/io.c:355:14: note: in expansion of macro ‘EXTRACT_DIGIT’
      355 |     case 19: EXTRACT_DIGIT(s, x, 1000000000000000000ULL, dot);
          |              ^~~~~~~~~~~~~
    In function ‘word_to_string’,
        inlined from ‘coeff_to_string’ at ./Modules/_decimal/libmpdec/io.c:410:13,
        inlined from ‘_mpd_to_string’ at ./Modules/_decimal/libmpdec/io.c:501:22:
    ./Modules/_decimal/libmpdec/io.c:348:40: warning: array subscript 0 is outside array bounds of ‘char[0]’ [-Warray-bounds]
      348 |         if (s == dot) *s++ = '.'; *s++ = '0' + (char)(x / d); x %= d
          |                                   ~~~~~^~~~~~~~~~~~~~~~~~~~~
    ./Modules/_decimal/libmpdec/io.c:355:14: note: in expansion of macro ‘EXTRACT_DIGIT’
      355 |     case 19: EXTRACT_DIGIT(s, x, 1000000000000000000ULL, dot);
          |              ^~~~~~~~~~~~~
    ./Modules/_decimal/libmpdec/io.c:348:40: warning: array subscript 0 is outside array bounds of ‘char[0]’ [-Warray-bounds]
      348 |         if (s == dot) *s++ = '.'; *s++ = '0' + (char)(x / d); x %= d
          |                                   ~~~~~^~~~~~~~~~~~~~~~~~~~~
    ./Modules/_decimal/libmpdec/io.c:356:14: note: in expansion of macro ‘EXTRACT_DIGIT’
      356 |     case 18: EXTRACT_DIGIT(s, x, 100000000000000000ULL, dot);
          |              ^~~~~~~~~~~~~
    Checked 110 modules (33 built-in, 76 shared, 1 n/a on linux-x86_64, 0 disabled, 0 missing, 0 failed on import)

    PS: _io_FileIO_close_impl() from the original report is already fixed.
    PPS: gcc version was mentioned above:

    $ gcc --version
    gcc (Debian 12.2.0-14) 12.2.0
  5. skrah commented on Jan 30, 2024

    @skrah
    Contributor

    Indeed, that is another false positive (-Warray-bounds this time). It is already disabled in mpdecimal-4.0.0.

    As explained in the linked gcc issue, the exact warning emitted depends on what path the optimizer takes.
    The key issue in both cases is that gcc does not like the (correct) if (s == dot) check.

    If you compile --with-strict-overflow and apply this patch, it should work:

    diff --git a/Modules/_decimal/libmpdec/io.c b/Modules/_decimal/libmpdec/io.c
    index e7bd6ae..adedde7 100644
    --- a/Modules/_decimal/libmpdec/io.c
    +++ b/Modules/_decimal/libmpdec/io.c
    @@ -46,6 +46,7 @@
     
     
     #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && __GNUC__ >= 7
    +  #pragma GCC diagnostic ignored "-Warray-bounds"
       #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
       #pragma GCC diagnostic ignored "-Wmisleading-indentation"
     #endif
    
  6. added 2 commits that reference this issue on Jan 30, 2024
  7. skirpichev commented on Jan 30, 2024

    @skirpichev
    MemberAuthor

    Thanks, that part was backported. See full patch: #114751

  8. added a commit that references this issue on Mar 3, 2024
  9. encukou commented on Mar 4, 2024

    @encukou
    Member

    When this PR was merged, LTO buildbots started failing. See for example: https://buildbot.python.org/all/#/builders/29/builds/5844

  10. reopened this on Mar 4, 2024
  11. erlend-aasland commented on Mar 4, 2024

    @erlend-aasland
    Contributor

    Ok, can you revert #114751, @encukou?

  12. 8 remaining items

  13. added a commit that references this issue on Mar 5, 2024
  14. skirpichev commented on Mar 5, 2024

    @skirpichev
    MemberAuthor
  15. erlend-aasland commented on Mar 5, 2024

    @erlend-aasland
    Contributor

    Thanks for the heads-up, Sergey! Closing as resolved.

  16. skirpichev commented on Mar 5, 2024

    @skirpichev
    MemberAuthor

    @erlend-aasland, warnings in the main are present. I think this issue isn't solved.

  17. added 2 commits that reference this issue on Mar 25, 2024
  18. added 2 commits that reference this issue on Apr 17, 2024
  19. skirpichev commented on Oct 6, 2024

    @skirpichev
    MemberAuthor

    @erlend-aasland, this should be fixed if we update bundled mpdecimal to v4. Does it make sense for you?

  20. erlend-aasland commented on Oct 6, 2024

    @erlend-aasland
    Contributor

    @erlend-aasland, this should be fixed if we update bundled mpdecimal to v4. Does it make sense for you?

    Aren't we trying to unbundle mpdecimal? :)

  21. skirpichev commented on Oct 6, 2024

    @skirpichev
    MemberAuthor

    Yes, but Debian people removed mpdecimal.

    UPD: ah, no. v4.0.0 doesn't include #116346

  22. vstinner commented on Oct 7, 2024

    @vstinner
    Member

    @erlend-aasland:

    Aren't we trying to unbundle mpdecimal? :)

    Right, What's New in Python 3.13 says:

    Pending Removal in Python 3.15: The bundled copy of libmpdecimal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions