Skip to content

NPE during JIT regex compilation on Corretto-21.0.11.10.1 #157

Description

@wmccall-amplify

Describe the bug

We ran into a SIGSEGV error which caused the JVM to crash and export a hs_err_pid<pid>.log file. The log reported the following:

  # A fatal error has been detected by the Java Runtime Environment:
  #  SIGSEGV (0xb) at pc=..., pid=..., tid=...
  # Problematic frame:
  # J ... c2 java.util.regex.Pattern.RemoveQEQuoting()V java.base@21.0.11 (370 bytes) @ 0x... [0x...+0x...]
  si_signo: 11 (SIGSEGV), si_code: 1 (SEGV_MAPERR), si_addr: 0x0000000000000000

Which seems to point to a null pointer dereference inside C2 JIT-compiled java.util.regex.Pattern.RemoveQEQuoting(). This caused downtime of our auth service in a production environment, negatively impacting many real users.

To Reproduce

Unfortunately we are unable to reproduce. We wrote a script to force the JVM to go through this path millions of times in an attempt to cause the error, but we were unsuccessful.

Expected behavior

JIT compiler successfully compiles regex and proceeds.

Screenshots

N/A

Platform information

We are running the open source auth service Keycloak v26.3.5 on EC2 instances with the following environment:

  • JRE: OpenJDK Runtime Environment Corretto-21.0.11.10.1 (21.0.11+10-LTS)
  • OS: Amazon Linux 2023
  • Uptime before crash: ~2.5 days

Additional context

  • Pattern being compiled at crash time: a single \x0A (newline) character — patternLength = 1
  • Call chain on stack: Matcher::replaceAll → Pattern::compile → RemoveQEQuoting
  • Crash occurred ~immediately after C2 JIT-compiled RemoveQEQuoting (compile timestamp matches crash timestamp within milliseconds), suggesting a C2 miscompilation rather than a pre-existing problem in the compiled code
  • Currently attempting to work around this issue with the java option -XX:CompileCommand=exclude,java.util.regex.Pattern::RemoveQEQuoting

redacted_hs_err_pid8906.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions