Skip to content

6.2.0: Unexpected output "Unknown constant: 11" #18360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
joeljeske opened this issue May 10, 2023 · 18 comments
Closed

6.2.0: Unexpected output "Unknown constant: 11" #18360

joeljeske opened this issue May 10, 2023 · 18 comments
Labels

Comments

@joeljeske
Copy link
Contributor

joeljeske commented May 10, 2023

Description of the bug:

After upgrading to 6.2.0, I am seeing many messages in build log that do not seem possible when reading the source code:

(02:31:14) INFO: From Extracting interface //my_target:my_target_with_header:
--
  | Unknown constant: 11. Passing class through.
  | Unknown constant: 11. Passing class through.
  | Unknown constant: 11. Passing class through.
  | Unknown constant: 11. Passing class through.
  | Unknown constant: 11. Passing class through.
  | Unknown constant: 11. Passing class through.
  | Unknown constant: 11. Passing class through.

This is the default case for https://github.com/bazelbuild/bazel/blob/release-6.2.0/third_party/ijar/classfile.cc#L1660-L1662
however the switch should have a case for constant 11 https://github.com/bazelbuild/bazel/blob/release-6.2.0/third_party/ijar/classfile.cc#L1593.

I am wanting to understand this error to see if there is anything I need to change on my end, or if its a bug here.

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

https://github.com/joeljeske/bazel-repo-iss18360

Which operating system are you running Bazel on?

Linux, and darwin

What is the output of bazel info release?

release 6.2.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

Have you found anything relevant by searching the web?

No response

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

No response

@sgowroji
Copy link
Member

Hi @joeljeske, Can you provide minimal steps followed to reproduce this issue. Thanks!

@joeljeske
Copy link
Contributor Author

joeljeske commented May 11, 2023

Hey @sgowroji I'm working towards a minimal reproduction, but have been debugging along the way.

Currently, HEAD of rules_java is referencing remote_java_tools v12.1, which supplies pre-built ijar binaries that should not be able to log this message according to ijar source code.

I am unable to traceback to the source code that built these binaries, as its not contained in the bazelbuild/java_tools repo itself. If I upgrade to 12.2 by specifying my own remote_java_tools in my WORKSPACE, then this message no longer appears. Edit: I was incorrect, I do experience this error with every version of java_tools/ijar. I think there may be something incorrect about origin of java_tools prebuilt binaries.

@joeljeske
Copy link
Contributor Author

@sgowroji Alright, here is a minimum reproduction! Its pretty simple and it does not occur in 6.1.0.

https://github.com/joeljeske/bazel-repo-iss18360

@joeljeske
Copy link
Contributor Author

Another realization: The message Unknown constant: 11. Passing class through. is printing a hexadecimal number 11, not the decimal number 17. This is why the message is printing in the first place. But I still do not know why this symbol is appearing 🤔

@Pavank1992 Pavank1992 added untriaged team-Remote-Exec Issues and PRs for the Execution (Remote) team and removed more data needed labels May 12, 2023
@dmivankov
Copy link
Contributor

same with jdk17 via build --java_runtime_version=remotejdk_17 --java_language_version=17 --tool_java_runtime_version=remotejdk_17 --tool_java_language_version=17

but it seems that the trigger is --collect_code_coverage=true, without it there's no warning

@dmivankov
Copy link
Contributor

17 is Constant_Dynamic from https://openjdk.org/jeps/309 which is part of jdk11

$ javap -c -v -classpath bazel-bin/src/liblib_b.jar lib/ClassB
...
public class lib.ClassB
  minor version: 0
  major version: 61
  flags: (0x0021) ACC_PUBLIC, ACC_SUPER
  this_class: #7                          // lib/ClassB
  super_class: #2                         // java/lang/Object
  interfaces: 0, fields: 0, methods: 2, attributes: 2
Constant pool:
...
  #24 = Dynamic            #0:#23         // #0:$jacocoData:Ljava/lang/Object;
...

so looks like third_party/ijar is missing support for that, not sure about the impact

@dmivankov
Copy link
Contributor

Probably it means generated ijar would be same as full jar and that may result in more recompilations

@dmivankov
Copy link
Contributor

Here it is suggested that jacoco uses it for jdk11 since 0.8.4 https://issuetracker.google.com/issues/178400721
Unclear why it pops up only now, third_party/java/jacoco is 0.8.6/0.8.7 in 6.1.2 and 6.2.0

@joeljeske
Copy link
Contributor Author

Great information, thank you! I was able to bypass this issue and generate proper ijars by downgrading remote_java_tools to 11.2.

There is this patch https://github.com/bazelbuild/bazel/blob/6.2.0/third_party/java/jacoco/0001-Disable-use-of-constant-dynamic-bytecode.patch that appears to workaround this exact issue, but was removed in 7.x. This made me question if remote_java_tools 12.x was generated from bazel 7.x... 🤔

benjaminp added a commit to benjaminp/bazel that referenced this issue May 15, 2023
benjaminp added a commit to benjaminp/bazel that referenced this issue May 15, 2023
benjaminp added a commit to benjaminp/bazel that referenced this issue May 15, 2023
benjaminp added a commit to benjaminp/bazel that referenced this issue May 15, 2023
@Pavank1992 Pavank1992 added team-Rules-Java Issues for Java rules and removed team-Remote-Exec Issues and PRs for the Execution (Remote) team labels May 16, 2023
@dmivankov
Copy link
Contributor

Is this going to be fixed in 6.2.2 or 6.3.0? Has been some time since 6.2.0 is out and non-upgradeable due to this regression

@fmeum
Copy link
Collaborator

fmeum commented Jun 14, 2023

CC @meteorcloudy

@meteorcloudy
Copy link
Member

/cc @hvadehra Can you take a look?

I guess this has something to do with the java_tools upgrade (-> 12.3) happened in 6.2.0, and I guess java_tools are built from the master branch of Bazel therefore contains newer changes?

@dmivankov I tried to reproduce this, it isn't a hard failure, why is this blocking your upgrade?

@dmivankov
Copy link
Contributor

I think it creates a performance regression where generated ijar would be same as jar and would cause more frequent recompilations especially on bigger projects

@meteorcloudy
Copy link
Member

I'll leave this to @hvadehra @cushon and the java team to investigate.

@cushon
Copy link
Contributor

cushon commented Jun 14, 2023

The fix in #18406 LGTM

copybara-service bot pushed a commit that referenced this issue Jun 14, 2023
#18360

Partial commit for third_party/*, see #18406.

Signed-off-by: Hee Cha <[email protected]>
iancha1992 pushed a commit to iancha1992/bazel that referenced this issue Jun 14, 2023
bazelbuild#18360

Partial commit for third_party/*, see bazelbuild#18406.

Signed-off-by: Hee Cha <[email protected]>
traversaro pushed a commit to traversaro/bazel that referenced this issue Jun 24, 2023
bazelbuild#18360

Partial commit for third_party/*, see bazelbuild#18406.

Signed-off-by: Hee Cha <[email protected]>
@dmivankov
Copy link
Contributor

Can probably be closed as fixed in 6.3.0 that was just released

@meteorcloudy
Copy link
Member

SG, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants