oracle / oracle/graalpython

[Bug]: NullPointerException in PythonLocaleData.getLocaleData

Open
#1,103 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
1.6k
Forks
155
Avg merge
9h 42m
Merged PRs (30d)
36

Description

Describe the bug

GraalPy crashes when running this fuzzed code:

import re
re.search('A', '', 9999)
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.NullPointerException: 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 com.oracle.truffle.regex/com.oracle.truffle.regex.flavor.python.PythonLocaleData.getLocaleData(PythonLocaleData.java:81)
	at com.oracle.truffle.regex/com.oracle.truffle.regex.flavor.python.PythonRegexLexer.getLocaleData(PythonRegexLexer.java:198)
	at com.oracle.truffle.regex/com.oracle.truffle.regex.flavor.python.PythonRegexLexer.caseFoldUnfold(PythonRegexLexer.java:348)
	at com.oracle.truffle.regex/com.oracle.truffle.regex.flavor.python.PythonRegexParser.literalChar(PythonRegexParser.java:315)
	at com.oracle.truffle.regex/com.oracle.truffle.regex.flavor.python.PythonRegexParser.parse(PythonRegexParser.java:244)
	at com.oracle.truffle.regex/com.oracle.truffle.regex.tregex.TRegexCompilationRequest.parse(TRegexCompilationRequest.java:349)
	at com.oracle.truffle.regex/com.oracle.truffle.regex.tregex.TRegexCompilationRequest.compileInternal(TRegexCompilationRequest.java:159)
	at com.oracle.truffle.regex/com.oracle.truffle.regex.tregex.TRegexCompilationRequest.compile(TRegexCompilationRequest.java:143)
	at com.oracle.truffle.regex/com.oracle.truffle.regex.tregex.TRegexCompiler.doCompile(TRegexCompiler.java:89)
	at com.oracle.truffle.regex/com.oracle.truffle.regex.tregex.TRegexCompiler.compile(TRegexCompiler.java:75)
	at com.oracle.truffle.regex/com.oracle.truffle.regex.RegexLanguage.createRegexObject(RegexLanguage.java:205)
	at com.oracle.truffle.regex/com.oracle.truffle.regex.RegexLanguage.parse(RegexLanguage.java:164)
	at org.graalvm.truffle/com.oracle.truffle.api.TruffleLanguage$ParsingRequest.parse(TruffleLanguage.java:1204)
	at org.graalvm.truffle/com.oracle.truffle.api.TruffleLanguage.parse(TruffleLanguage.java:1618)
	at org.graalvm.truffle/com.oracle.truffle.api.LanguageAccessor$LanguageImpl.parse(LanguageAccessor.java:309)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotSourceCache.parseImpl(PolyglotSourceCache.java:114)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotSourceCache$WeakCache.lookup(PolyglotSourceCache.java:351)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotSourceCache.parseCached(PolyglotSourceCache.java:94)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotLanguageContext.parseCached(PolyglotLanguageContext.java:377)
	at org.graalvm.truffle/com.oracle.truffle.polyglot.EngineAccessor$EngineImpl.parseForLanguage(EngineAccessor.java:332)
	at org.graalvm.truffle/com.oracle.truffle.api.TruffleLanguage$Env.parseInternal(TruffleLanguage.java:2648)
	at org.graalvm.py/com.oracle.graal.python.builtins.modules.re.TRegexCache.compile(TRegexCache.java:307)
	at org.graalvm.py/com.oracle.graal.python.builtins.modules.re.PatternNodes$TRegexCompileNode.getCompiledRegexLocaleNonSensitive(PatternNodes.java:220)
	at org.graalvm.py/com.oracle.graal.python.builtins.modules.re.PatternNodes$TRegexCompileNode.localeNonSensitive(PatternNodes.java:228)
	at org.graalvm.py/com.oracle.graal.python.builtins.modules.re.PatternNodesFactory$TRegexCompileNodeGen.executeAndSpecialize(PatternNodesFactory.java:841)
	at org.graalvm.py/com.oracle.graal.python.builtins.modules.re.PatternNodesFactory$TRegexCompileNodeGen.execute(PatternNodesFactory.java:752)
	at org.graalvm.py/com.oracle.graal.python.builtins.modules.re.PatternBuiltins$NewNode.newPattern(PatternBuiltins.java:188)
	at org.graalvm.py/com.oracle.graal.python.builtins.modules.re.PatternBuiltinsFactory$NewNodeFactory$NewNodeGen.execute(PatternBuiltinsFactory.java:248)
	at org.graalvm.py/com.oracle.graal.python.nodes.function.builtins.BuiltinCallNode$BuiltinAnyCallNode.execute(BuiltinCallNode.java:64)
	at org.graalvm.py/com.oracle.graal.python.nodes.function.BuiltinFunctionRootNode.execute(BuiltinFunctionRootNode.java:337)
[...snip...]
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the crash with the supplied re.search('A', '', 9999) snippet, then inspect PythonLocaleData.java at line 81 and the regex entry points named in the stack trace. Add regression coverage for this input and verify that it completes without a NullPointerException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.