Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.12] gh-127637: add tests fordis command-line interface (#127759)#127780

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@picnixz
Copy link
Member

@picnixzpicnixz commentedDec 10, 2024
edited by bedevere-appbot
Loading

@picnixz
Copy link
MemberAuthor

Apparently,test_embed get stucked. I won't have time for more work until Friday (and I can't test it since I don't have a Windows testing machine).

@iritkatriel
Copy link
Member

Apparently,test_embed get stucked. I won't have time for more work until Friday (and I can't test it since I don't have a Windows testing machine).

I doubt it's related to this PR.

picnixz reacted with thumbs up emoji

@picnixz
Copy link
MemberAuthor

@iritkatriel Do you want to merge this as is?

@iritkatriel
Copy link
Member

@iritkatriel Do you want to merge this as is?

I can't, the button is greyed out when there are failing tests.

@picnixz
Copy link
MemberAuthor

Ok, so the tests consistently fail. Other backports PRs don't have this issue. I'll disable the automerge and check if removing the test actually changes something.

@picnixz
Copy link
MemberAuthor

picnixz commentedDec 28, 2024
edited
Loading

What I found is thattest_specialized_static_code_gets_unspecialized_at_Py_FINALIZE importsdis. I'm not sure if there is something happening because of this (maybesys.argv is incorrectly picked up? or something else? I don't know)

@picnixz
Copy link
MemberAuthor

OK so now the tests passed. I don't know why. Is it because oftempfile perhaps?

@picnixz
Copy link
MemberAuthor

Ok, so after some investigation it appears that theimport test.test_dis was the bad line. I don't really know why but I assume it has to be because of some import magic. Failures related to WMI should however be unrelated.

@picnixzpicnixz marked this pull request as ready for reviewDecember 28, 2024 11:50
@picnixz
Copy link
MemberAuthor

picnixz commentedDec 28, 2024
edited
Loading

@iritkatriel Can you perhaps explain to me why removing the import oftest.test_dis made the test work? is it because of themain() function ofdis that has been changed? is it because of thetempfile import? or is it because I'm importingopcode beforetest* and others?

@iritkatriel
Copy link
Member

@iritkatriel Can you perhaps explain to me why removing the import oftest.test_dis made the test work? is it because of themain() function ofdis that has been changed? is it because of thetempfile import? or is it because I'm importingopcode beforetest* and others?

I don't know. Could you squash the commits so that the diff between the working and non working versions is clear, and then we can ask an import expert?

@picnixzpicnixz marked this pull request as draftDecember 28, 2024 12:17
@picnixzpicnixzforce-pushed thebp-e85f2f1703e0f79cfd0d0e3010190b71c0eb18da branch froma610c0e to68a33f3CompareDecember 28, 2024 12:17
@picnixz
Copy link
MemberAuthor

picnixz commentedDec 28, 2024
edited
Loading

Ok, now here's the commit that fixed everything:68a33f3

@picnixzpicnixz marked this pull request as ready for reviewDecember 28, 2024 12:23
@iritkatriel
Copy link
Member

Ok, now here's the commit that fixed everything:68a33f3

ok, now revert this commit so we see the error, but leave this commit and the revert commit in the log.

This reverts commit68a33f3.
@picnixz
Copy link
MemberAuthor

ok, now revert this commit so we see the error,

AFAIR, the error was a timeout (after 20 minutes) and a simple "FAIL". But the stacktrace could help the import expert (AFAICT, the execution appears to wait for some input, and I thought it was because it was trying to rundis.main() itself but maybe it's something else)

@iritkatriel
Copy link
Member

ok, now revert this commit so we see the error,

AFAIR, the error was a timeout (after 20 minutes) and a simple "FAIL". But the stacktrace could help the import expert (AFAICT, the execution appears to wait for some input, and I thought it was because it was trying to rundis.main() itself but maybe it's something else)

It didn't happen on 3.13, right?

@picnixz
Copy link
MemberAuthor

It didn't happen on 3.13, right?

No, the 3.13 backport went well.

@iritkatriel
Copy link
Member

It didn't happen on 3.13, right?

No, the 3.13 backport went well.

Let's see if the release manager for 3.12 has any ideas then.@Yhg1s

@Yhg1s
Copy link
Member

Yhg1s commentedJan 14, 2025
edited
Loading

I think the bug this exposes is real, but not caused by the change here. It may just be a bug in test_embed's test program (Programs/_testembed.c). I managed to reproduce it locally (on Windows). The timeout is because the _testembed program crashes, and Windows (in debug builds) produces a popup dialog asking if you want to abort. It is a real abort, an assertion failure:

PS D:\Python\cpython> D:\\Python\\cpython\\PCbuild\\amd64\\_testembed_d.exe test_repeated_init_exec 'import dis>> import importlib._bootstrap>> import opcode>> import test.test_dis>>>> def is_specialized(f):>>     for instruction in dis.get_instructions(f, adaptive=True):>>         opname = instruction.opname>>         if (>>             opname in opcode._specialized_instructions>>             # Exclude superinstructions:>>             and \"__\" not in opname>>         ):>>             return True>>     return False>>>> func = importlib._bootstrap._handle_fromlist>>>> # "copy" the code to un-specialize it:>> func.__code__ = func.__code__.replace()>>>> assert not is_specialized(func), \"specialized instructions found\">>>> for i in range(test.test_dis.ADAPTIVE_WARMUP_DELAY):>>     func(importlib._bootstrap, [\"x\"], lambda *args: None)>>>> assert is_specialized(func), \"no specialized instructions found\">>>> print(\"Tests passed\")'--- Loop #1 ---Tests passed--- Loop #2 ---Assertion failed: PyUnicode_CheckExact(ep->me_key), file D:\Python\cpython\Objects\dictobject.c, line 939

As you can see it happens on the second time running the test code (after finalizing and reinitializing), and theep the assertion fails on is a deallocated object. I think the problem is something isn't refcounted correctly, isn't marked as immortal when it should be, or isn't recreated on interpreter starutp when it should be. I don't know why it doesn't reproduce on Linux in debug mode.

I'm not comfortable enough with the Windows debugging environment to dig into this more. I'm pretty sure this is only a problem with repeatedPy_Finalize/Py_Initialize calls. If either of you want to start an educational deep-dive into object reclamation/recreation during interpreter finalization and initialization, feel free, but since this only happens in 3.12, and lots has changed in 3.13 already around object lifetimes, I'm happy with the workaround you have as well. (I think the test is neater if it doesn't try to import test_dis anyway.)

@picnixz
Copy link
MemberAuthor

@vstinner I plan to merge this one with no commit message and the PR as the title.

vstinner reacted with thumbs up emoji

Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM

@picnixzpicnixz merged commitfbbef60 intopython:3.12Jan 18, 2025
31 checks passed
@picnixzpicnixz deleted the bp-e85f2f1703e0f79cfd0d0e3010190b71c0eb18da branchJanuary 18, 2025 11:02
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@vstinnervstinnervstinner approved these changes

@iritkatrieliritkatrielAwaiting requested review from iritkatriel

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@picnixz@iritkatriel@Yhg1s@vstinner

[8]ページ先頭

©2009-2025 Movatter.jp