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

The JIT's understanding of** is wrong #127809

Closed
Assignees
brandtbucher
Labels
3.14bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-JITtype-crashA hard crash of the interpreter, possibly with a core dump
@brandtbucher

Description

@brandtbucher

Crash report

** is weird in that thetype of the result depends on thevalues of the inputs. The logic forint/float power is:

deftype_of_pow(lhs:float,rhs:float)->type[complex]:ifisinstance(lhs,int)andisinstance(rhs,int)andrhs>=0:returnintiflhs<0andnotrhs.is_integer():returncomplexreturnfloat

However, our optimizer wrongly assumes:

deftype_of_pow(lhs:float,rhs:float)->type[float]:ifisinstance(lhs,int)andisinstance(rhs,int):returnintreturnfloat

This means that tons of different poorly-chosen values can cause JIT code to crash:

import_testinternalcapiimportitertoolsdeff(a,b):for_inrange(_testinternalcapi.TIER2_THRESHOLD):a+b# Remove guards...a**b+a# ...BOOM!forla,ra,lb,rbinitertools.product([1,-1,1.0,-1.0,0.5,-0.5],repeat=4):f(la,ra)f(lb,rb)

Normally we could just ignore the problem and produce an unknown type during abstract interpretation, but a** containing at least one constant value is actually reasonably common (thinkx ** 2,2 ** n, ors ** 0.5).

We should probably teach the optimizer how to handle these properly.

Linked PRs

Metadata

Metadata

Assignees

Labels

3.14bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-JITtype-crashA hard crash of the interpreter, possibly with a core dump

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2026 Movatter.jp