[Bug]: `compile()` with unrecognised flags raises a `ValueError` whose message crashes with `NullPointerException`
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 1.7k
- Forks
- 163
- Merge médio
- 8h 15min
- PRs com merge (30d)
- 49
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de oracle/graalpython
-
[Bug]: `reversed()` on a dict or dict view returns the forward iterator type instead of `dict_reverse*iterator`Talvez já em andamento @jseop-lim assumiu há 3 dias. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
oracle/graalpython#1226 ·
Mantenedores costumam responder em até 1 dia
-
[Bug]: `complex(real, imag)` converts `imag` before rejecting a non-number `real`Talvez já em andamento @jseop-lim assumiu há 3 dias. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
oracle/graalpython#1225 ·
Mantenedores costumam responder em até 1 dia
-
[Bug]: sys.flags.debug is 1 whenever optimization is offTalvez já em andamento @hippi345 assumiu há 6 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
oracle/graalpython#1213 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
oracle/graalpython#1105 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
oracle/graalpython#1102 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de oracle/graalpython
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
foxglove/mcap#1907 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
namespace operations
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
EclipseFdn/open-vsx.org#14623 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
developmentseed/titiler-cmr#261 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
andrewyng/openworker#774 ·
Mantenedores costumam responder em até 1 dia
-
aggfuncAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
worldbank/blackmarblepy#160 ·