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

bpo-38115: Deal with invalid bytecode offsets in lnotab #16079

Merged
merged 2 commits into from Sep 28, 2019

Conversation

Yhg1s
Copy link
Member

@Yhg1s Yhg1s commented Sep 13, 2019

For terrible reasons that are difficult to fix, a code object's co_lnotab can contain invalid bytecode offsets (offsets past the end of the bytecode string). Make dis.findlinestarts() ignore invalid offsets in lnotab. All other uses of lnotab in CPython -- various reimplementations of addr2line or line2addr in Python, C and gdb -- already ignore this (because they take an address to look for, instead of parsing the whole thing).

Add tests for the result of dis.findlinestarts() on wacky constructs in test_peepholer.py, because it's the easiest place to add them.

https://bugs.python.org/issue38115

terrible reasons that are difficult to fix). Make dis.findlinestarts()
ignore invalid offsets in lnotab. All other uses of lnotab in CPython
(various reimplementations of addr2line or line2addr in Python, C and gdb)
already ignore this, because they take an address to look for, instead.

Add tests for the result of dis.findlinestarts() on wacky constructs in
test_peepholer.py, because it's the easiest place to add them.
zooba
zooba approved these changes Sep 27, 2019
@gpshead gpshead merged commit c816503 into python:master Sep 28, 2019
4 checks passed
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Sep 28, 2019

Thanks @Yhg1s for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒🤖

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Sep 28, 2019

Sorry, @Yhg1s and @gpshead, I could not cleanly backport this to 3.8 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker c8165036f374cd2ee64d4314eeb2514f7acb5026 3.8

gpshead pushed a commit to gpshead/cpython that referenced this issue Sep 28, 2019
Document that lnotab can contain invalid bytecode offsets (because of
terrible reasons that are difficult to fix). Make dis.findlinestarts()
ignore invalid offsets in lnotab. All other uses of lnotab in CPython
(various reimplementations of addr2line or line2addr in Python, C and gdb)
already ignore this, because they take an address to look for, instead.

Add tests for the result of dis.findlinestarts() on wacky constructs in
test_peepholer.py, because it's the easiest place to add them.

(cherry picked from commit c816503)
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Sep 28, 2019

GH-16464 is a backport of this pull request to the 3.8 branch.

gpshead added a commit that referenced this issue Sep 28, 2019
…H-16464)

Document that lnotab can contain invalid bytecode offsets (because of
terrible reasons that are difficult to fix). Make dis.findlinestarts()
ignore invalid offsets in lnotab. All other uses of lnotab in CPython
(various reimplementations of addr2line or line2addr in Python, C and gdb)
already ignore this, because they take an address to look for, instead.

Add tests for the result of dis.findlinestarts() on wacky constructs in
test_peepholer.py, because it's the easiest place to add them.

(cherry picked from commit c816503)
jacobneiltaylor pushed a commit to jacobneiltaylor/cpython that referenced this issue Dec 5, 2019
Document that lnotab can contain invalid bytecode offsets (because of
terrible reasons that are difficult to fix). Make dis.findlinestarts()
ignore invalid offsets in lnotab. All other uses of lnotab in CPython
(various reimplementations of addr2line or line2addr in Python, C and gdb)
already ignore this, because they take an address to look for, instead.

Add tests for the result of dis.findlinestarts() on wacky constructs in
test_peepholer.py, because it's the easiest place to add them.
jneb pushed a commit to jneb/cpython that referenced this issue Jan 13, 2021
…) (pythonGH-16464)

Document that lnotab can contain invalid bytecode offsets (because of
terrible reasons that are difficult to fix). Make dis.findlinestarts()
ignore invalid offsets in lnotab. All other uses of lnotab in CPython
(various reimplementations of addr2line or line2addr in Python, C and gdb)
already ignore this, because they take an address to look for, instead.

Add tests for the result of dis.findlinestarts() on wacky constructs in
test_peepholer.py, because it's the easiest place to add them.

(cherry picked from commit c816503)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants