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

_PyPegen_raise_error_known_location() uses wrong build format #95876

Closed
Assignees
tiranpablogsal
Labels
3.11only security fixes3.12only security fixestype-bugAn unexpected behavior, bug, or error
@tiran

Description

@tiran

Bug report

_PyPegen_raise_error_known_location() usesPy_BuildValue() to generate a tuple for SyntaxError. The format string uses wrong values for all integer constants. lineno, col_number, end_lineno, and end_col_number are Py_ssize_t. Thei format string handles int. This causes memory corruption on 64bit operation systems with strict ABI (e.g. wasm64).

}
tmp=Py_BuildValue("(OiiNii)",p->tok->filename,lineno,col_number,error_line,end_lineno,end_col_number);
if (!tmp) {
gotoerror;

I can reliable crash the interpreter with a syntax error like1+=1. Notice the<ensc object at 0x1> in the object dump.

$ node --experimental-wasm-memory64 ./python.js -c "1+=1"  File "<string>", line 1object address  : 0x973e10object refcount : 2object type     : 0x2bc868object type name: SyntaxErrorobject repr     : SyntaxError("'literal' is an illegal expression for augmented assignment", ('<string>', 1, 0, <ensc object at 0x1>, 10590200, 0))lost sys.stderrAborted(Runtime error: The application has corrupted its heap memory area (address zero)!)exiting due to exception: RuntimeError: Aborted(Runtime error: The application has corrupted its heap memory area (address zero)!),RuntimeError: Aborted(Runtime error: The application has corrupted its heap memory area (address zero)!)    at abort (/home/heimes/dev/python/cpython/builddir/wasm64-emscripten-node-debug/python.js:971:11)    at checkStackCookie (/home/heimes/dev/python/cpython/builddir/wasm64-emscripten-node-debug/python.js:733:47)    at exitRuntime (/home/heimes/dev/python/cpython/builddir/wasm64-emscripten-node-debug/python.js:800:3)    at exitJS (/home/heimes/dev/python/cpython/builddir/wasm64-emscripten-node-debug/python.js:7254:9)    at callMain (/home/heimes/dev/python/cpython/builddir/wasm64-emscripten-node-debug/python.js:9476:5)    at doRun (/home/heimes/dev/python/cpython/builddir/wasm64-emscripten-node-debug/python.js:9525:23)    at run (/home/heimes/dev/python/cpython/builddir/wasm64-emscripten-node-debug/python.js:9540:5)    at runCaller (/home/heimes/dev/python/cpython/builddir/wasm64-emscripten-node-debug/python.js:9448:19)    at removeRunDependency (/home/heimes/dev/python/cpython/builddir/wasm64-emscripten-node-debug/python.js:936:7)    at receiveInstance (/home/heimes/dev/python/cpython/builddir/wasm64-emscripten-node-debug/python.js:1106:5)

The fix is trivial, usen instead ofi.https://docs.python.org/3/c-api/arg.html#c.Py_BuildValue

Your environment

CPython main
wasm64-emscripten (EMSDK 3.1.18) with Node 16

Metadata

Metadata

Labels

3.11only security fixes3.12only security fixestype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp