-
Notifications
You must be signed in to change notification settings - Fork 63
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
Python 3.11 support #1902
Python 3.11 support #1902
Conversation
Shouldn't the CI configuration in this branch also be changed to work with Python 11? |
Actually, I would like to make sure the branch works with Python 3.10. It does not yet work with Python 3.11. |
Bump Python installation from `3.10` to `3.11`
I updated the CI config to that effect in 3bc9562... |
From what I understood from @cmnrd, this PR provides fixes for a problem that shouldn't exist in the first place (or, rather, should be solved in a different way). He implied that we are not incompatible with Python 11 as is, and that the segmentation fault occurs due to building using with one version of Python and then running with another. |
I'm referring to #1458 (comment). |
I may be wrong about this, but let me defer to @cmnrd for the review of this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR makes Python 3.11 required. Is this really what we want? I think we should aim at continuing the Python 3.10 support in order to also support running on Debian and the latest Ubuntu LTS release. This would mean, however, that we should also run tests for both Python versions.
core/src/main/java/org/lflang/generator/python/PythonReactionGenerator.java
Outdated
Show resolved
Hide resolved
I think there is some confusion about the python errors, and I am not sure what this PR fixes. On my Linux machine with Python 3.11 things seem to run fine without any errors even on master. However, given that earlier CI runs in this PR actually failed, it looks like there are other error than the segmentation fault caused by incompatible Python runtimes. |
I updated this branch today (merged in master, also updated the submodule and merged in reactor-c main) and extended CI so that we test both Python 3.10 and 3.11. However, now the tests fail again and I don't know what is going on. Must be some change that happened in the meantime in LF or reactor-c. |
@jackykwok2024, could you please take a look at this? |
I have consistently reproduced the error using the
Upon comparing the output logs between Python 3.10 and Python 3.11, I noticed a significant discrepancy in the reference count for the Output from Python 3.11: As a result, my conjecture is that this issue arises from a deep recursion in
According to the official documentation of Python 3.11, there is an optimization update for recursive functions and the C stack in Python to Python calls is removed (python/cpython#89419) However, I'm uncertain whether this is the underlying issue. |
Thanks, @jackykwok2024, that's a really good find! I agree that it seems plausible that this optimization is to blame... Seems hard to fix if true. Do you have any ideas? |
I don't see any recursion in Count3Modes.lf, so it's not clear how this optimization could be related. ??? |
I figured there may be recursion involved with the mode transitions or set implementation, but I could well be wrong... |
Sorry for the confusion in my previous comments. My initial conjecture was that the inflated reference count might have been due to recursion involved with the In Python 3.10 and earlier, the function These immortal objects have an artificially inflated reference count, for example, 1000000161 instead of a typical smaller number. This is what we are observing as the reference count in the This issue seems to be unrelated to the segfault but could lead to confusion for developers during the debugging process… |
A minor issue is that with python 3.11, we get a deprecation warning that should be easy to fix:
This will require a fix in reactor-c. |
Python 3.11 support in the C runtime (still not supported in lingua-franca, however). See [1902](lf-lang/lingua-franca#1902)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I noticed that we're increasing the testing burden by testing both Python 3.10 and 3.11. What should be the policy going forward? What range of Python version do we plan to support?
Have we made progress in figuring out why the tests do not pass?
It is up to us to decide which Python versions to support. With Mocasin we aim to support the 3 latest versions. I think we should aim to support at least the latest version, as well as the version used by the latest LTS Ubuntu (and Debian) releases (which is 3.10 at the moment). |
Since Python 3.12 was released recently, we should actually also add it to the matrix. |
I noticed that this PR has stalled. Is there any ambition to resurrect this effort? |
I have no bandwidth to resurrect this, but we have a bigger problem, which is that CMake should not be choosing the Python version. We need a target property or some such. See #2298. |
This is superseded by #2441. |
This is an attempt to get the python target to work with Python 11. It gets past the segfault, but when it imports the generated C module, Python for some reason fails to recognize the result as an extension module. For example, the ActionDelay.lf test gives this error message: