Skip to content

JDK 20 update broke non-ascii argument encoding on macOS #18792

Closed
@tetromino

Description

@tetromino

Description of the bug:

Non-ascii arguments to spawned tools (both in genrule and in ctx.actions.run) are encoded as mojibake garbage with Bazel at HEAD on macOS.

Everything works fine with Bazel 6.2.1 on macOS, and with any Bazel version (including at HEAD) on Linux.

bazelisk bisect identified ecf9b9a as the culprit.

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

BUILD file:

genrule(
    name = "genrule",
    cmd = "echo привет > \"$@\"",
    outs = ["genrule.out"],
)

With Bazel at HEAD on macOS, get garbage:

$ USE_BAZEL_VERSION=last_green bazelisk build //:genrule && cat bazel-bin/genrule.out
2023/06/27 14:55:01 Using unreleased version at commit 044a14cca2747aeff258fc71eaeb153c08cb34d5
INFO: Analyzed target //:genrule (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //:genrule up-to-date:
  bazel-bin/genrule.out
INFO: Elapsed time: 0.152s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
пÑ�ивеÑ

With Bazel 6.2.1 on macOS, get expected result:

$ bazelisk build //:genrule && cat bazel-bin/genrule.out
INFO: Analyzed target //:genrule (5 packages loaded, 7 targets configured).
INFO: Found 1 target...
Target //:genrule up-to-date:
  bazel-bin/genrule.out
INFO: Elapsed time: 3.882s, Critical Path: 0.10s
INFO: 2 processes: 1 internal, 1 darwin-sandbox.
INFO: Build completed successfully, 2 total actions
привет

Which operating system are you running Bazel on?

macOS Ventura 13.4.1

What is the output of bazel info release?

development version

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

Bazelisk with USE_BAZEL_VERSION=last_green

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.

ecf9b9a

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2We'll consider working on this in future. (Assignee optional)team-OSSIssues for the Bazel OSS team: installation, release processBazel packaging, websitetype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions