[Bug]: ClassCastException with hashlib and `__new__`
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
Reproduce the hashlib sha3_224.new('') snippet on GraalPy and start with the CApiTransitions and WrapperDescriptorRootNodes entry points named in the stack trace. Trace the conversion made during the new call and add regression coverage for this input. Done means the snippet no longer crashes with ClassCastException.
Written by the indexing model from the issue text.
Description
Describe the bug
GraalPy crashes when running this fuzzed code:
from hashlib import sha3_224
sha3_224.__new__('')
Operating system
Linux
CPU architecture
x86_64
GraalPy version
GraalPy 3.13.14 (Oracle GraalVM Native 25.3.4.1)
JDK version
No response
Context configuration
No response
Steps to reproduce
Snippet listed above
Expected behavior
No crash
Stack trace
java.lang.ClassCastException: Stack trace is imprecise, the top frames are missing and/or have wrong line numbers. To get precise stack traces, build the image with option -H:-ReduceImplicitExceptionStackTraceInformation
at org.graalvm.py/com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions$PythonToNativeInternalNode.doGeneric(CApiTransitions.java:1865)
at org.graalvm.py/com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitionsFactory$PythonToNativeInternalNodeGen$Inlined.executeAndSpecialize(CApiTransitionsFactory.java:849)
at org.graalvm.py/com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitionsFactory$PythonToNativeInternalNodeGen$Inlined.execute(CApiTransitionsFactory.java:775)
at org.graalvm.py/com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions$PythonToNativeInternalNode.execute(CApiTransitions.java:1727)
at org.graalvm.py/com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitions$PythonToNativeNode.doGeneric(CApiTransitions.java:1995)
at org.graalvm.py/com.oracle.graal.python.builtins.objects.cext.capi.transitions.CApiTransitionsFactory$PythonToNativeNodeGen.execute(CApiTransitionsFactory.java:1147)
at org.graalvm.py/com.oracle.graal.python.builtins.objects.cext.capi.WrapperDescriptorRootNodesGen$MethNewRootGen.invokeExternalFunction(WrapperDescriptorRootNodesGen.java:106)
at org.graalvm.py/com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes$MethNewRoot.readArgumentsAndInvokeExternalFunction(ExternalFunctionNodes.java:900)
at org.graalvm.py/com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes$WrapperBaseRoot.execute(ExternalFunctionNodes.java:524)
at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:808)
at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:722)
at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:641)
at org.graalvm.truffle.runtime.svm/com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget.invokeCallBoundary(SubstrateOptimizedCallTarget.java:124)
at com.oracle.truffle.enterprise.svm/com.oracle.svm.enterprise.truffle.compiler.SubstrateEnterpriseOptimizedCallTarget.invokeCompiledAdapterOrCallBoundary(SubstrateEnterpriseOptimizedCallTarget.java:293)
at com.oracle.truffle.enterprise.svm/com.oracle.svm.enterprise.truffle.compiler.SubstrateEnterpriseOptimizedCallTarget.invokeFromInterpreter(SubstrateEnterpriseOptimizedCallTarget.java:269)
at com.oracle.truffle.enterprise.svm/com.oracle.svm.enterprise.truffle.compiler.SubstrateEnterpriseOptimizedCallTarget.doInvoke(SubstrateEnterpriseOptimizedCallTarget.java:255)
at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.callDirect(OptimizedCallTarget.java:573)
at org.graalvm.truffle.runtime/com.oracle.truffle.runtime.OptimizedCallTarget.call(OptimizedCallTarget.java:519)
at org.graalvm.truffle/com.oracle.truffle.api.nodes.IndirectCallNode$1.call(IndirectCallNode.java:96)
at org.graalvm.py/com.oracle.graal.python.nodes.call.CallDispatchers$SimpleIndirectInvokeNode.doIndirect(CallDispatchers.java:167)
at org.graalvm.py/com.oracle.graal.python.nodes.call.CallDispatchersFactory$SimpleIndirectInvokeNodeGen$Uncached.execute(CallDispatchersFactory.java:307)
at org.graalvm.py/com.oracle.graal.python.nodes.call.CallDispatchers$BuiltinMethodCachedCallNode.callBuiltinMethodMegamorphic(CallDispatchers.java:324)
at org.graalvm.py/com.oracle.graal.python.nodes.call.CallDispatchersFactory$BuiltinMethodCachedCallNodeGen$Uncached.execute(CallDispatchersFactory.java:1758)
at org.graalvm.py/com.oracle.graal.python.nodes.call.CallNode.builtinMethodCall(CallNode.java:187)
at org.graalvm.py/com.oracle.graal.python.nodes.call.CallNodeGen$Uncached.executeInternal(CallNodeGen.java:627)
at org.graalvm.py/com.oracle.graal.python.nodes.call.CallNode.execute(CallNode.java:128)
at org.graalvm.py/com.oracle.graal.python.nodes.call.special.CallBinaryMethodNode.call(CallBinaryMethodNode.java:181)
at org.graalvm.py/com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNodeGen$CallBinaryMethod_Node.execute$uncached(PBytecodeDSLRootNodeGen.java)
at org.graalvm.py/com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNodeGen$UncachedBytecodeNodeTailCall.handleCallBinaryMethod_(PBytecodeDSLRootNodeGen.java:37865)
at org.graalvm.py/com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNodeGen$UncachedBytecodeNodeTailCall.__stub_handleCallBinaryMethod_(PBytecodeDSLRootNodeGen.java:0)
at org.graalvm.py/com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNodeGen$UncachedBytecodeNodeTailCall.continueAt(PBytecodeDSLRootNodeGen.java:35093)
at org.graalvm.py/com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNodeGen.continueAt(PBytecodeDSLRootNodeGen.java:3501)
at org.graalvm.py/com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNodeGen.execute(PBytecodeDSLRootNodeGen.java:3493)
[...snip...]
Additional context
No response
- Dominant language
- Python
- Stars
- 1.6k
- Forks
- 155
- Avg merge
- 8h 58m
- Merged PRs (30d)
- 39
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from oracle/graalpython
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
oracle/graalpython#1105 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
oracle/graalpython#1102 ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
oracle/graalpython#1157 · 1 assignee ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 74/100
oracle/graalpython#1133 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
oracle/graalpython#1112 ·
All issues in oracle/graalpython
Similar issues
-
essnmx good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
[Feature] 奇物选择添加优先级 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
syfoud/Simulated_Scepter#174 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Giskard-AI/giskard-oss#2840 · 1 comment ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Openarea: repo bug perceived difficulty: 2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
yeti-platform/yeti#1380 ·