Open
Description
Description of the bug:
I had an invalid regex in a rewrite
in my downloader config, and bazel would just crash without an error message.
Running it with --batch
, I was able to see the error message, however, e.g.:
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 4
(.*\maven.org/.*)
^
at java.base/java.util.regex.Pattern.error(Unknown Source)
at java.base/java.util.regex.Pattern.escape(Unknown Source)
at java.base/java.util.regex.Pattern.atom(Unknown Source)
at java.base/java.util.regex.Pattern.sequence(Unknown Source)
at java.base/java.util.regex.Pattern.expr(Unknown Source)
at java.base/java.util.regex.Pattern.group0(Unknown Source)
at java.base/java.util.regex.Pattern.sequence(Unknown Source)
at java.base/java.util.regex.Pattern.expr(Unknown Source)
at java.base/java.util.regex.Pattern.compile(Unknown Source)
at java.base/java.util.regex.Pattern.<init>(Unknown Source)
at java.base/java.util.regex.Pattern.compile(Unknown Source)
at com.google.devtools.build.lib.bazel.repository.downloader.UrlRewriterConfig.<init>(UrlRewriterConfig.java:134)
at com.google.devtools.build.lib.bazel.repository.downloader.UrlRewriter.<init>(UrlRewriter.java:77)
at com.google.devtools.build.lib.bazel.repository.downloader.UrlRewriter.getDownloaderUrlRewriter(UrlRewriter.java:98)
at com.google.devtools.build.lib.bazel.BazelRepositoryModule.beforeCommand(BazelRepositoryModule.java:409)
at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:412)
at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:244)
at com.google.devtools.build.lib.runtime.BlazeRuntime.batchMain(BlazeRuntime.java:953)
at com.google.devtools.build.lib.runtime.BlazeRuntime.main(BlazeRuntime.java:763)
at com.google.devtools.build.lib.bazel.Bazel.main(Bazel.java:95)
Which category does this issue belong to?
Core
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
I just created an empty MODULE.bazel
and a simple downloader.cfg
file with a bad regex (invalid \m
escape)
downloader.cfg
:
rewrite (.*\maven.org/.*) http://example.com/mirror/$1
And then:
% bazel --nosystem_rc --output_user_root=$PWD/root info --experimental_downloader_config=downloader.config
Starting local Bazel server and connecting to it...
% echo $?
37
Which operating system are you running Bazel on?
alma linux 9
What is the output of bazel info release
?
release 7.0.0
If bazel info release
returns development version
or (@non-git)
, tell us how you built Bazel.
No response
What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD
?
No response
Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
It appears to be crashing since the config flag was introduced in 9d29464, but in that version, there's an error message on the output.
% USE_BAZEL_VERSION=9d2946440a43c2adc6b3cdf09739a6dbf5e29abf bazelisk --nosystem_rc --output_user_root=$PWD/root info --experimental_downloader_config=downloader.config
WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
/etc/bazel.bazelrc
Starting local Bazel server and connecting to it...
Internal error thrown during build. Printing stack trace: java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 4
(.*\maven.org/.*)
^
at java.base/java.util.regex.Pattern.error(Unknown Source)
at java.base/java.util.regex.Pattern.escape(Unknown Source)
at java.base/java.util.regex.Pattern.atom(Unknown Source)
at java.base/java.util.regex.Pattern.sequence(Unknown Source)
at java.base/java.util.regex.Pattern.expr(Unknown Source)
at java.base/java.util.regex.Pattern.group0(Unknown Source)
at java.base/java.util.regex.Pattern.sequence(Unknown Source)
at java.base/java.util.regex.Pattern.expr(Unknown Source)
at java.base/java.util.regex.Pattern.compile(Unknown Source)
at java.base/java.util.regex.Pattern.<init>(Unknown Source)
at java.base/java.util.regex.Pattern.compile(Unknown Source)
at com.google.devtools.build.lib.bazel.repository.downloader.UrlRewriterConfig.<init>(UrlRewriterConfig.java:118)
at com.google.devtools.build.lib.bazel.repository.downloader.UrlRewriter.<init>(UrlRewriter.java:63)
at com.google.devtools.build.lib.bazel.repository.downloader.UrlRewriter.getDownloaderUrlRewriter(UrlRewriter.java:82)
at com.google.devtools.build.lib.bazel.BazelRepositoryModule.beforeCommand(BazelRepositoryModule.java:286)
at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:388)
at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:236)
at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:546)
at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$1(GrpcServerImpl.java:611)
at io.grpc.Context$1.run(Context.java:579)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 4
Have you found anything relevant by searching the web?
Any other information, logs, or outputs that you want to share?
Java RPM info:
Name : java-11-openjdk-devel
Epoch : 1
Version : 11.0.19.0.7
Release : 4.el9.alma
Activity