Title: [2.7] test_audioop.test_max() failed: AssertionError: -2147483648 != 2147483648L
Type: Stage:
Components: Build Versions: Python 2.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: deep42thought, vstinner
Priority: normal Keywords:

Created on 2018-07-11 13:10 by deep42thought, last changed 2018-07-13 13:01 by deep42thought.

File name Uploaded Description Edit
log.reduced deep42thought, 2018-07-11 13:10 output of the last command
pythoninfo deep42thought, 2018-07-13 09:11
Messages (6)
msg321449 - (view) Author: Erich Eckner (deep42thought) Date: 2018-07-11 13:10
building python 2.7.15 on archlinux32 (the i686 branch of archlinux) from source succeeds, but running the testsuite (with some segfaulting tests disabled - see issue34095) results in an assertion error:

test_wrongsize (test.test_audioop.TestAudioop) ... test test_audioop failed -- Traceback (most recent call last):
  File "/home/vagrant/python2/src/Python-2.7.15/Lib/test/", line 48, in test_max
    self.assertEqual(audioop.max(p(minvalues[w]), w), -minvalues[w])
AssertionError: -2147483648 != 2147483648L


FAIL: test_max (test.test_audioop.TestAudioop)
Traceback (most recent call last):
  File "/home/vagrant/python2/src/Python-2.7.15/Lib/test/", line 48, in test_max
    self.assertEqual(audioop.max(p(minvalues[w]), w), -minvalues[w])
AssertionError: -2147483648 != 2147483648L

The commands leading to this are:

  cd Python-${pkgver}

  # Temporary workaround for FS#22322
  # See for upstream report
  sed -i "/progname =/s/python/python${_pybasever}/" Python/pythonrun.c

  # Enable built-in SQLite module to load extensions (fix FS#22122)

  # FS#23997
  sed -i -e "s|^#.* /usr/local/bin/python|#!/usr/bin/python2|" Lib/

  sed -i "s/python2.3/python2/g" Lib/distutils/tests/ \

  # Ensure that we are using the system copy of various libraries (expat, zlib and libffi),
  # rather than copies shipped in the tarball
  rm -r Modules/expat
  rm -r Modules/zlib
  rm -r Modules/_ctypes/{darwin,libffi}*

  # clean up #!s
  find . -name '*.py' | \
    xargs sed -i "s|#[ ]*![ ]*/usr/bin/env python$|#!/usr/bin/env python2|"

  # Workaround errors after we touched the shebangs
  touch Include/Python-ast.h Python/Python-ast.c Python/opcode_targets.h

  # FS#48761
  patch -Np1 -i ../descr_ref.patch

  export OPT="${CFLAGS}"
  ./configure --prefix=/usr \
              --enable-shared \
              --with-threads \
              --enable-optimizations \
              --with-lto \
              --enable-ipv6 \
              --enable-unicode=ucs4 \
              --with-system-expat \
              --with-system-ffi \
              --with-dbmliborder=gdbm:ndbm \


  LD_LIBRARY_PATH="${srcdir}/Python-${pkgver}":${LD_LIBRARY_PATH} \
    xvfb-run "${srcdir}/Python-${pkgver}/python" -m test.regrtest -v -uall -x test_idle test_bytes test_str test_string test_unicode test_userstring test_tuple test_tk test_ttk_guionly test_ctypes 2>&1 | tee log.reduced
msg321454 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-07-11 14:15
It seems like you are using [GCC 8.1.1 20180531]. Can you please run the following command and attach the created "pythoninfo" file to his issue?

./python -m test.pythoninfo > pythoninfo

I'm looking for your CFLAGS.

I guess that the issue is specific to 32-bit, but we have many "x86" buildbots building Python on various compilers and running the test suite, and all these buildbots are green (success).
msg321584 - (view) Author: Erich Eckner (deep42thought) Date: 2018-07-13 09:11
yes, I'm using gcc (GCC) 8.1.1 20180531
I attached the created pythoninfo
msg321592 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-07-13 11:00
Extract of attached test.pythoninfo output:

sys.maxsize: 2147483647
sysconfig[PY_CFLAGS]: -fno-strict-aliasing -march=i686 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -DNDEBUG -march=i686 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -I. -IInclude -I./Include -D_FORTIFY_SOURCE=2 -fPIC -DPy_BUILD_CORE

I tried to reproduce the issue on my x86_64 Fedora 28 (64-bit) using:

   ./configure CFLAGS="-m32" LDFLAGS="-m32" && make

But I failed to reproduce the issue. I also tried to add "-fstack-protector-strong -fno-plt" but I still fail to reproduce the bug.

On interesting thing is that your CFLAGS don't contain -fwrapv. You can try the following command to check if gcc -v --help contains -fwrapv?

"gcc -v --help|grep -- -fwrapv"

With my french locale, for example, I see:

  -fwrapv                     Supposer que le débordement de l'arithmétique signée boucle sur la plage accessible.

You may try to force -fwrapv using ./configure CFLAGS="-fwrapv" or directly by adding directly the option to the OPT variable in Makefile. Example of options on my x86_64 Fedora and "./configure":

OPT=		-DNDEBUG -g -fwrapv -O3 -Wall
BASECFLAGS=	 -Wno-unused-result -Wsign-compare
CONFIGURE_CFLAGS_NODIST= -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration

Note: When Python is compiled with --with-pydebug, -fwrapv is not used.

Note: Your CFLAGS use -O2 whereas Python uses -O3 by default in release mode.
msg321604 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-07-13 12:59
I installed Fedora 28 in 32-bit (GCC 8.1.1) in a VM to try to reproduce the bug, but I failed to reproduce it.

Erich Eckner: IMHO your issue comes from a C flag. Try to loop on:

touch Modules/audioop.c && make && ./python -m test test_audioop

And remove flags from PY_CFLAGS in Makefile, one by one, until the bug goes away, to try to identify which C flags causes your issue.
msg321606 - (view) Author: Erich Eckner (deep42thought) Date: 2018-07-13 13:01
yes, indeed, I just tested with your three flags-variables set and the build+test succeeded - I'll have to figure out what the minimal change is, though :-)
Date User Action Args
2018-07-13 13:01:54deep42thoughtsetmessages: + msg321606
2018-07-13 12:59:30vstinnersetmessages: + msg321604
2018-07-13 11:00:46vstinnersetmessages: + msg321592
2018-07-13 09:11:51deep42thoughtsetfiles: + pythoninfo

messages: + msg321584
2018-07-11 14:15:55vstinnersetnosy: + vstinner
messages: + msg321454
2018-07-11 14:04:32vstinnersettitle: testsuite fails assertion -> [2.7] test_audioop.test_max() failed: AssertionError: -2147483648 != 2147483648L
2018-07-11 13:10:57deep42thoughtcreate