[Bug]: `compile()` with unrecognised flags raises a `ValueError` whose message crashes with `NullPointerException`
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start in graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java at CompileNode.checkFlags, then compare its raiseStatic call with the adjacent checkOptimize path and read the exception formatting path in ExceptionNodes.java. Reproduce with the supplied Python snippet and confirm that reading the caught ValueError message no longer crashes and matches compile(): unrecognised flags; check for a regression test covering the case.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
compile() with an unrecognised flags value raises a ValueError that can be caught, but reading its message (str(e), repr(e) or e.args) throws a Java NullPointerException and terminates the process.
Operating system
Linux
CPU architecture
x86_64
GraalPy version
25.0.2 (Python 3.12.8); also reproduced on 25.4.4.1.1 (Python 3.13.14) and on master 7e7182b103
JDK version
No response
Context configuration
No response
Steps to reproduce
try:
compile('1', 'f', 'exec', 0x7fffffff)
except ValueError as e:
print(e)
GraalPy master prints nothing and exits with the NullPointerException below (exit status 1; 25.0.2 exits with status 0).
Expected behavior
CPython 3.12.13 (same on 3.13.16):
compile(): unrecognised flags
Stack trace
java.lang.NullPointerException: Cannot invoke "com.oracle.truffle.api.strings.TruffleString.toJavaStringUncached()" because "format" is null
at org.graalvm.py/com.oracle.graal.python.builtins.objects.exception.ExceptionNodes$GetArgsNode.getFormattedMessage(ExceptionNodes.java:371)
at org.graalvm.py/com.oracle.graal.python.builtins.objects.exception.ExceptionNodes$GetArgsNode.doManaged(ExceptionNodes.java:396)
at org.graalvm.py/com.oracle.graal.python.builtins.objects.exception.ExceptionNodesFactory$GetArgsNodeGen$Inlined.executeAndSpecialize(ExceptionNodesFactory.java:1951)
at org.graalvm.py/com.oracle.graal.python.builtins.objects.exception.ExceptionNodesFactory$GetArgsNodeGen$Inlined.execute(ExceptionNodesFactory.java:1934)
at org.graalvm.py/com.oracle.graal.python.builtins.objects.exception.BaseExceptionBuiltins$StrNode.str(BaseExceptionBuiltins.java:511)
Additional context
The same crash happens for a bytes source, a negative flags, and the generic path (compile(None, 'f', 'exec', 0x10000)).
Root Cause
CompileNode.checkFlags raises with PRaiseNode.raiseStatic(this, ValueError, null, NO_VALUE, ErrorMessages.UNRECOGNIZED_FLAGS, PythonUtils.EMPTY_OBJECT_ARRAY) (BuiltinFunctions.java#L1143-L1148). That binds to the raiseStatic(Node, type, TruffleString message, Object... formatArgs) overload (PRaiseNode.java#L107-L112), so the exception gets a null message format, and formatting it lazily fails in ExceptionNodes.java#L370-L371. CPython sets a plain message (bltinmodule.c#L757-L763).
Fix Suggestion
Use the message overload, PRaiseNode.raiseStatic(this, ValueError, ErrorMessages.UNRECOGNIZED_FLAGS), as checkOptimize next to it does.
- Ngôn ngữ chính
- Python
- Star
- 1.7k
- Fork
- 163
- Merge trung bình
- 8 giờ 15 phút
- Pull request đã merge (30 ngày)
- 49
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của oracle/graalpython
-
[Bug]: `reversed()` on a dict or dict view returns the forward iterator type instead of `dict_reverse*iterator`Có thể đã có người làm @jseop-lim đã nhận 3 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
oracle/graalpython#1226 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: `complex(real, imag)` converts `imag` before rejecting a non-number `real`Có thể đã có người làm @jseop-lim đã nhận 3 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
oracle/graalpython#1225 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: sys.flags.debug is 1 whenever optimization is offCó thể đã có người làm @hippi345 đã nhận 6 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
oracle/graalpython#1213 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
oracle/graalpython#1105 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
oracle/graalpython#1102 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của oracle/graalpython
Issue tương tự
-
Python Volcengine provider returns failures instead of raising themCó thể đã có người làm @Ricardo-M-L đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
agent-infra/sandbox#248 ·
-
Textractor leaves empty temporary files when remote retrieval failsCó thể đã có người làm @HuaTNA đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
test(bm_generation): pin the learning parameters and CPU sync shortcutCó thể đã có người làm @iloveeyjafjalla đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
qboson/kaiwu-pytorch-plugin#1341 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
elder-plinius/V3R1T4S#625 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
foxglove/mcap#1907 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày