Skip to content
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

Data race in field readOnlyBearerAuth in class RegistryClient.java #4374

Open
raulpardo opened this issue Mar 27, 2025 · 0 comments · May be fixed by #4375
Open

Data race in field readOnlyBearerAuth in class RegistryClient.java #4374

raulpardo opened this issue Mar 27, 2025 · 0 comments · May be fixed by #4375

Comments

@raulpardo
Copy link

raulpardo commented Mar 27, 2025

Environment:

  • Jib version 3.4.5:
  • Build tool: Gradle 6.9.2
  • OS: Ubuntu 24.04

Description of the issue:

There is a data race (according to the Java memory model) in the field readOnlyBearerAuth in class RegistryClient.java. Due to this data race, it is possible that writes on the variable by one thread are not visible to other threads reading the variable in the future. This can happen, for instance, if two threads concurrent execute doPullBearerAuth() and doPushBearerAuth().

Expected behavior:

Threads reading stale or outdated writes on the field readOnlyBearerAuth in class RegistryClient.java

Steps to reproduce:

Consider two threads t1 and t2 and let readOnlyBearerAuth==false. Consider that t1 executes doPullBearerAuth() and concurrently t2 executes doPushBearerAuth(). The following execution can occur:

  1. t1 reads readOnlyBearerAuth as false in this line
  2. t1 sets the corresponding authenticator
  3. t2 reads readOnlyBearerAuth as false (because there is no happens-before relation between the write by t1 and this read and the java memory model does not ensure that the write by t1 is visible to t2)

Additional Information:

The problem can be solved by defining readOnlyBearerAuth as volatile.

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

Successfully merging a pull request may close this issue.

2 participants