Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion failure when running "test_ast" tests with coverage. #71781

Closed
ap mannequin opened this issue Jul 22, 2016 · 8 comments
Closed

Assertion failure when running "test_ast" tests with coverage. #71781

ap mannequin opened this issue Jul 22, 2016 · 8 comments
Labels
tests Tests in the Lib/test dir

Comments

@ap
Copy link
Mannequin

ap mannequin commented Jul 22, 2016

BPO 27594
Nosy @birkenfeld, @benjaminp, @ned-deily, @pquentin, @ilevkivskyi

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2016-08-17.21:24:31.497>
created_at = <Date 2016-07-22.22:32:06.393>
labels = ['tests']
title = 'Assertion failure when running "test_ast" tests with coverage.'
updated_at = <Date 2016-08-17.21:34:04.305>
user = 'https://bugs.python.org/ap'

bugs.python.org fields:

activity = <Date 2016-08-17.21:34:04.305>
actor = 'levkivskyi'
assignee = 'none'
closed = True
closed_date = <Date 2016-08-17.21:24:31.497>
closer = 'ned.deily'
components = ['Tests']
creation = <Date 2016-07-22.22:32:06.393>
creator = 'ap'
dependencies = []
files = []
hgrepos = []
issue_num = 27594
keywords = []
message_count = 8.0
messages = ['271038', '271891', '272527', '272549', '272859', '272988', '272992', '272994']
nosy_count = 8.0
nosy_names = ['georg.brandl', 'benjamin.peterson', 'ned.deily', 'SilentGhost', 'python-dev', 'Quentin.Pradet', 'levkivskyi', 'ap']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue27594'
versions = ['Python 3.6']

@ap
Copy link
Mannequin Author

ap mannequin commented Jul 22, 2016

This is with a build of the default branch on OS X 10.11.6:

$ hg identify
fada654c5f72 tip
$ ./python.exe --version
Python 3.6.0a3+
$

The "test_ast" tests appear to run fine without coverage tracking enabled:

$ ./python.exe -m test test_ast
Run tests sequentially
0:00:00 [1/1] test_ast
1 test OK.
Total duration: 0:00:07
$

But when coverage tracking is enabled, an assertion fails:

$ ./python.exe -m test --coverage -D`pwd`/coverage_data test_ast
Run tests sequentially
0:00:00 [1/1] test_ast
Assertion failed: (line > 0), function _PyCode_CheckLineNumber, file Objects/codeobject.c, line 717.
Fatal Python error: Aborted

Current thread 0x00007fff76279000 (most recent call first):
File "test", line 0 in <module>
File "/python-dev/cpython/Lib/test/test_ast.py", line 559 in test_level_as_none
File "/python-dev/cpython/Lib/unittest/case.py", line 600 in run
File "/python-dev/cpython/Lib/unittest/case.py", line 648 in __call__
File "/python-dev/cpython/Lib/unittest/suite.py", line 122 in run
File "/python-dev/cpython/Lib/unittest/suite.py", line 84 in __call__
File "/python-dev/cpython/Lib/unittest/suite.py", line 122 in run
File "/python-dev/cpython/Lib/unittest/suite.py", line 84 in __call__
File "/python-dev/cpython/Lib/unittest/suite.py", line 122 in run
File "/python-dev/cpython/Lib/unittest/suite.py", line 84 in __call__
File "/python-dev/cpython/Lib/test/support/init.py", line 1709 in run
File "/python-dev/cpython/Lib/test/support/init.py", line 1810 in _run_suite
File "/python-dev/cpython/Lib/test/support/init.py", line 1844 in run_unittest
File "/python-dev/cpython/Lib/test/libregrtest/runtest.py", line 179 in test_runner
File "/python-dev/cpython/Lib/test/libregrtest/runtest.py", line 180 in runtest_inner
File "/python-dev/cpython/Lib/test/libregrtest/runtest.py", line 144 in runtest
File "<string>", line 1 in <module>
File "/python-dev/cpython/Lib/trace.py", line 469 in runctx
File "/python-dev/cpython/Lib/test/libregrtest/main.py", line 330 in run_tests_sequential
File "/python-dev/cpython/Lib/test/libregrtest/main.py", line 406 in run_tests
File "/python-dev/cpython/Lib/test/libregrtest/main.py", line 466 in _main
File "/python-dev/cpython/Lib/test/libregrtest/main.py", line 446 in main
File "/python-dev/cpython/Lib/test/libregrtest/main.py", line 508 in main
File "/python-dev/cpython/Lib/test/main.py", line 2 in <module>
File "/python-dev/cpython/Lib/runpy.py", line 85 in _run_code
File "/python-dev/cpython/Lib/runpy.py", line 184 in _run_module_as_main
Abort trap: 6
$

@ap ap mannequin added the tests Tests in the Lib/test dir label Jul 22, 2016
@SilentGhost
Copy link
Mannequin

SilentGhost mannequin commented Aug 3, 2016

Cannot reproduce this on Linux

@ilevkivskyi
Copy link
Member

You could try changing this line in compile.c (in function 'assemble')

if (entryblock && entryblock->b_instr)

to

if (entryblock && entryblock->b_instr && entryblock->b_instr->i_lineno)

Does this help?

@pquentin
Copy link
Mannequin

pquentin mannequin commented Aug 12, 2016

Thanks levkivskyi, it fixed the issue for me!

@ap
Copy link
Mannequin Author

ap mannequin commented Aug 16, 2016

Thanks, Ivan, that change fixes it for me, too.

I checked with a more recent revision and build:

$ hg identify
265644bad99e+ tip
$ ./python.exe --version
Python 3.6.0a4+
$ 

Confirmed that it still exhibited the same behaviour as before:

$ ./python.exe -m test test_ast
Run tests sequentially
0:00:00 [1/1] test_ast
1 test OK.
Total duration: 0:00:06
$ 

$ ./python.exe -m test --coverage -D`pwd`/coverage_data test_ast
Run tests sequentially
0:00:00 [1/1] test_ast
Assertion failed: (line > 0), function _PyCode_CheckLineNumber, file Objects/codeobject.c, line 717.
Fatal Python error: Aborted

Current thread 0x00007fff7b5a7000 (most recent call first):
File "test", line 0 in <module>
File "/python-dev/cpython/Lib/test/test_ast.py", line 559 in test_level_as_none
File "/python-dev/cpython/Lib/unittest/case.py", line 600 in run
File "/python-dev/cpython/Lib/unittest/case.py", line 648 in __call__
File "/python-dev/cpython/Lib/unittest/suite.py", line 122 in run
File "/python-dev/cpython/Lib/unittest/suite.py", line 84 in __call__
File "/python-dev/cpython/Lib/unittest/suite.py", line 122 in run
File "/python-dev/cpython/Lib/unittest/suite.py", line 84 in __call__
File "/python-dev/cpython/Lib/unittest/suite.py", line 122 in run
File "/python-dev/cpython/Lib/unittest/suite.py", line 84 in __call__
File "/python-dev/cpython/Lib/test/support/init.py", line 1709 in run
File "/python-dev/cpython/Lib/test/support/init.py", line 1810 in _run_suite
File "/python-dev/cpython/Lib/test/support/init.py", line 1844 in run_unittest
File "/python-dev/cpython/Lib/test/libregrtest/runtest.py", line 179 in test_runner
File "/python-dev/cpython/Lib/test/libregrtest/runtest.py", line 180 in runtest_inner
File "/python-dev/cpython/Lib/test/libregrtest/runtest.py", line 144 in runtest
File "<string>", line 1 in <module>
File "/python-dev/cpython/Lib/trace.py", line 469 in runctx
File "/python-dev/cpython/Lib/test/libregrtest/main.py", line 330 in run_tests_sequential
File "/python-dev/cpython/Lib/test/libregrtest/main.py", line 406 in run_tests
File "/python-dev/cpython/Lib/test/libregrtest/main.py", line 466 in _main
File "/python-dev/cpython/Lib/test/libregrtest/main.py", line 446 in main
File "/python-dev/cpython/Lib/test/libregrtest/main.py", line 508 in main
File "/python-dev/cpython/Lib/test/main.py", line 2 in <module>
File "/python-dev/cpython/Lib/runpy.py", line 85 in _run_code
File "/python-dev/cpython/Lib/runpy.py", line 184 in _run_module_as_main
Abort trap: 6
$

I applied the change you suggested, and this was the result:

$ ./python.exe -m test --coverage -D`pwd`/coverage_data test_ast
Run tests sequentially
0:00:00 [1/1] test_ast
1 test OK.
lines   cov%   module   (path)
  556     1%   _collections_abc   (/python-dev/cpython/Lib/_collections_abc.py)
  147    25%   _weakrefset   (/python-dev/cpython/Lib/_weakrefset.py)
   96    16%   abc   (/python-dev/cpython/Lib/abc.py)
  156    66%   ast   (/python-dev/cpython/Lib/ast.py)
  418     1%   codecs   (/python-dev/cpython/Lib/codecs.py)
  692     0%   collections.__init__   (/python-dev/cpython/Lib/collections/__init__.py)
  166     8%   contextlib   (/python-dev/cpython/Lib/contextlib.py)
  318    22%   dis   (/python-dev/cpython/Lib/dis.py)
   74     5%   genericpath   (/python-dev/cpython/Lib/genericpath.py)
  103     2%   importlib.__init__   (/python-dev/cpython/Lib/importlib/__init__.py)
 1776     0%   inspect   (/python-dev/cpython/Lib/inspect.py)
 1228     0%   locale   (/python-dev/cpython/Lib/locale.py)
  170     0%   multiprocessing.process   (/python-dev/cpython/Lib/multiprocessing/process.py)
  612     1%   os   (/python-dev/cpython/Lib/os.py)
  687     0%   platform   (/python-dev/cpython/Lib/platform.py)
  313     5%   posixpath   (/python-dev/cpython/Lib/posixpath.py)
  435     1%   sysconfig   (/python-dev/cpython/Lib/sysconfig.py)
  336     1%   test.libregrtest.main   (/python-dev/cpython/Lib/test/libregrtest/main.py)
  174    29%   test.libregrtest.runtest   (/python-dev/cpython/Lib/test/libregrtest/runtest.py)
  197    27%   test.libregrtest.save_env   (/python-dev/cpython/Lib/test/libregrtest/save_env.py)
 1341     3%   test.support.__init__   (/python-dev/cpython/Lib/test/support/__init__.py)
  870    98%   test.test_ast   (/python-dev/cpython/Lib/test/test_ast.py)
  461     0%   trace   (/python-dev/cpython/Lib/trace.py)
  285     2%   traceback   (/python-dev/cpython/Lib/traceback.py)
  824    20%   unittest.case   (/python-dev/cpython/Lib/unittest/case.py)
  329     8%   unittest.loader   (/python-dev/cpython/Lib/unittest/loader.py)
  134    20%   unittest.result   (/python-dev/cpython/Lib/unittest/result.py)
  222    44%   unittest.suite   (/python-dev/cpython/Lib/unittest/suite.py)
  134     0%   unittest.util   (/python-dev/cpython/Lib/unittest/util.py)
  384     6%   weakref   (/python-dev/cpython/Lib/weakref.py)
Total duration: 0:00:09
$

@python-dev
Copy link
Mannequin

python-dev mannequin commented Aug 17, 2016

New changeset 1bf307f42a6b by Ned Deily in branch 'default':
Issue bpo-27594: Prevent assertion error when running test_ast with coverage
https://hg.python.org/cpython/rev/1bf307f42a6b

@ned-deily
Copy link
Member

Thanks for the report. It looks the assert error is triggered by the new test case added in 59638baee25e for bpo-13436. Since that test case was only added for 3.6, I've only applied Ivan's suggested fix for 3.6 as well, although you could trigger the same assert in earlier releases. Thanks, Ivan!

@ilevkivskyi
Copy link
Member

Ned, thank you for applying the patch!

I have discovered this same issue accidentally while playing with possible implementations of PEP-526. It appeared as a failure in
test_sys_settrace in my fork.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir
Projects
None yet
Development

No branches or pull requests

2 participants