Downgrade to Python 3.7 due to stack corruption in Python 3.8+#12298
Merged
michaelDCurran merged 8 commits intomasterfrom Apr 20, 2021
Merged
Downgrade to Python 3.7 due to stack corruption in Python 3.8+#12298michaelDCurran merged 8 commits intomasterfrom
michaelDCurran merged 8 commits intomasterfrom
Conversation
…cur when using SAPI4 and perhaps in other places, due to Python bug 38748.
Collaborator
|
Assuming that this is likely to take a while to be resolved (given that they
didn't before now), is it possible we could jump straight to 3.10 instead of
continuing incrementally to 3.8, after this is fixed?
|
Member
Author
|
This definitely should be considered, yes.
|
Contributor
|
Contributor
|
Please also revert #12141. |
Contributor
|
Have you considered bringing back code from #12042 which prevents people from attempting to build with Python 3.7.6? While it is unlikely someone would try the warning in the readme and in the sconscript does no harm and the code is already written. |
Contributor
|
Hi, I think it doesn’t matter as latest binary release is 3.7.9 (of course the latest release is 3.7.10 which is source code only release). Thanks.
|
feerrenrut
suggested changes
Apr 19, 2021
Contributor
feerrenrut
left a comment
There was a problem hiding this comment.
Looks good to me.
- As mentioned by @lukaszgo1, we should remove the lines from the userguide: #12141
- It makes sense to reintroduce the code to check for 3.7.6 from #12042. That version of python does not work with NVDA, although it is old, people are often unaware they are on an old version.
# in sconscript
if sys.version_info.micro == 6:
# #10696: Building with Python 3.7.6 fails. Innform user and exit.
Py376FailMsg = "Building with Python 3.7.6 is not possible.\nPlease use more recent version of Python 3."
raise RuntimeError(Py376FailMsg)
Collaborator
|
Although perhaps correct the spelling of "inform" from "Innform".
And insert the word "a" before the word "more" in the error message.
Reef Turner wrote:
… # in sconscript
if sys.version_info.micro == 6:
# #10696: Building with Python 3.7.6 fails. Innform user and exit.
Py376FailMsg = "Building with Python 3.7.6 is not possible.\nPlease use more recent version of Python 3."
raise RuntimeError(Py376FailMsg)
|
feerrenrut
approved these changes
Apr 20, 2021
Contributor
feerrenrut
left a comment
There was a problem hiding this comment.
Thanks @michaelDCurran
codeofdusk
added a commit
to codeofdusk/nvda
that referenced
this pull request
Sep 25, 2023
nvaccess#12298)" This reverts commit e019a24.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue number:
Fixes #12152
Fixes #12154
Summary of the issue:
Since upgrading to Python 3.8, several serious crashes in NVDA have been reported. Specifically:
Both of these issues were traced to stack corruption after a Python callback of NVDA's was called from external libraries. In SAPI4's case, after calling NVDA's implementation of
ITTSBufNotifySink::TextDataStarted, and in the Windows Server 2012 case:IUIAutomationPropertyChangedEventHandler::handlePropertyChangedEvent.It seems as though
libFFI/ Pythonctypesis not cleaning the stack properly after executing a Python callback with thestdcallcalling convention (ctypes WINFUNCTYPE), where the callback contained at least one argument larger than 4 bytes (E.g. along long, or aVARIANT struct), and the arguments preceding it were such that this argument was not aligned to an 8 byte boundary. E.g. the callback might be:callback(void*, long long)orcallback(void*, void*, int, VARIANT)See Python bug: https://bugs.python.org/issue38748
On that bug I have attached a minimal testcase.
This bug affects both Python 3.8 and Python 3.9.
The bug is most likely in the
libFFIproject used by Python'sctypesmodule. Python 3.8 switched to a much more recent and official version oflibFFII believe.Although we do really want to move to Python 3.8+ as soon as we can, right now this bug makes it impossible to do so. We could specifically work around the currently known manifestations by moving some of that code into C++, but that brings its own risks, and we still don't know where else this issue may appear in our code. The appropriate thing to do right now is stay on Python 3.7 until we can work with Python /
libFFIto get this resolved.Description of how this pull request fixes the issue:
Downgrades to Python 3.7 by referencing Python 3.7 (rather than 3.8) in NVDA's build system.
The existing PRs that needed to be reverted were:
brlAPIto a Python 3.8 build: BRLAPI for Python 3.8 nvda-misc-deps#20pgettext: Python 3.8/gettext: replace custom pgettext implementation with built--in pgettext #12109os.add_dll_directorywhen loadingliblouis: Python 3.8/liblouis helper: add NVDA executable path by calling os.add_dll_directory #12020None of these PRs provided any user visible changes.
The rest of the Python 3.8 work, including the switch to a virtual
environment etc is all compatible with Python 3.7 and can remain.
Testing strategy:
Known issues with pull request:
Change log entry:
None needed.
Code Review Checklist:
This checklist is a reminder of things commonly forgotten in a new PR.
Authors, please do a self-review and confirm you have considered the following items.
Mark items you have considered by checking them.
You can do this when editing the Pull request description with an x:
[ ]becomes[x].You can also check the checkboxes after the PR is created.