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

Fix TracebackFrameProxy.set_next() on Python 3.7 #1051

Merged
merged 1 commit into from Sep 4, 2019
Merged

Fix TracebackFrameProxy.set_next() on Python 3.7 #1051

merged 1 commit into from Sep 4, 2019

Conversation

vstinner
Copy link
Contributor

Fix issue #1050: fix a crash in TracebackFrameProxy.set_next() on
Python 3.7 and newer, when Python is build in debug mode.

Since Python 3.7, traceback.tb_next field can be modified: ctypes is
no longer needed.

@vstinner
Copy link
Contributor Author

Example on my Fedora 30 with python3-debug = Python 3.7.4.

Without this change, Python does crash:

$ python3-debug -m venv env
$ env/bin/python setup.py install
$ env/bin/python -m pip install pytest
$ env/bin/python -m pytest --tb=short -Werror 
...
$ env/bin/python -m pytest --tb=short -Werror -s tests/test_api.py 
======================================================================== test session starts ========================================================================
platform linux -- Python 3.7.4, pytest-5.1.0, py-1.8.0, pluggy-0.12.0
rootdir: /home/vstinner/jinja, inifile: setup.cfg
collected 27 items                                                                                                                                                  

tests/test_api.py ......../builddir/build/BUILD/Python-3.7.4/Modules/gcmodule.c:263: update_refs: Assertion "((gc)->gc.gc_refs >> (1)) != 0" failed.
object  : <refcnt 0 at 0x7fe081241660>
type    : traceback
refcount: 0
address : 0x7fe081241660
Fatal Python error: Aborted

Current thread 0x00007fe08fa41680 (most recent call first):
  File "/home/vstinner/jinja/jinja2/nodes.py", line 171 in iter_child_nodes
  File "/home/vstinner/jinja/jinja2/visitor.py", line 43 in generic_visit
  File "/home/vstinner/jinja/jinja2/visitor.py", line 39 in visit
  (...)

With this change, the whole test suite pass:

vstinner@apu$ env/bin/python -m pytest --tb=short -Werror 
=================================== test session starts ====================================
platform linux -- Python 3.7.4, pytest-5.1.0, py-1.8.0, pluggy-0.12.0
rootdir: /home/vstinner/jinja, inifile: setup.cfg, testpaths: tests
collected 582 items                                                                        

tests/test_api.py ...........................                                        [  4%]
tests/test_async.py ............................................                     [ 12%]
tests/test_asyncfilters.py ....................................                      [ 18%]
tests/test_bytecode_cache.py ...                                                     [ 18%]
tests/test_core_tags.py ............................................................ [ 29%]
..                                                                                   [ 29%]
tests/test_debug.py ....                                                             [ 30%]
tests/test_ext.py .........................................                          [ 37%]
tests/test_features.py .s                                                            [ 37%]
tests/test_filters.py .............................................................. [ 48%]
.......................................                                              [ 54%]
tests/test_idtracking.py .....                                                       [ 55%]
tests/test_imports.py ...........                                                    [ 57%]
tests/test_inheritance.py ................                                           [ 60%]
tests/test_lexnparse.py ............................................................ [ 70%]
.............................................                                        [ 78%]
tests/test_loader.py .................s..                                            [ 81%]
tests/test_nativetypes.py ..............                                             [ 84%]
tests/test_regression.py ................s........................                   [ 91%]
tests/test_security.py ...............                                               [ 93%]
tests/test_tests.py ...........................                                      [ 98%]
tests/test_utils.py ........                                                         [100%]

============================== 579 passed, 3 skipped in 3.13s ==============================

@vstinner

This comment has been minimized.

@davidism

This comment has been minimized.

Fix issue #1050: fix a crash in TracebackFrameProxy.set_next() on
Python 3.7 and newer, when Python is build in debug mode.

Since Python 3.7, traceback.tb_next field can be modified: ctypes is
no longer needed.
@davidism davidism changed the base branch from master to 2.10.x September 4, 2019 14:41
@davidism davidism added this to the 2.10.2 milestone Sep 4, 2019
@davidism davidism merged commit 72fffe4 into pallets:2.10.x Sep 4, 2019
@vstinner vstinner deleted the tb_next_py37 branch September 4, 2019 15:34
@vstinner
Copy link
Contributor Author

vstinner commented Sep 4, 2019

Thanks ;-)

@davidism
Copy link
Member

davidism commented Sep 4, 2019

No problem, I also merged it up to master. This will go out when 2.10.2 is released, but I can't make a guarantee on when that will be.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants