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

Variables show wrong value when debugging #7696

Open
frankvdh opened this issue Aug 25, 2024 · 9 comments
Open

Variables show wrong value when debugging #7696

frankvdh opened this issue Aug 25, 2024 · 9 comments
Labels
debugger Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) kind:bug Bug report or fix needs:triage Requires attention from one of the committers

Comments

@frankvdh
Copy link

Apache NetBeans version

Apache NetBeans 22

What happened

I am not sure of what triggers the fault, but in the Variables window, the wrong value is displayed for some variables. I have only seen this with java.awt.Point variables. In the attached screenshot, the value of this.curr.p is displayed as four different values in 4 places...

The Watch curr.p says its value is [6,3] in the summary line, yet the individual fields are x=2, y=1
In the Variables, this.curr.p shows [2, 2] in the summary line, with x=0 and y=0 for the individual fields.

The correct value is x=2, y=1

Screenshot 2024-08-26 045712

Language / Project Type / NetBeans Component

No response

How to reproduce

I am sorry, but I don't know what triggers this. I have only ever seen it in my current project in the last few weeks. I don't recall when it first happened, but certainly not 6 months ago. Possibly it was introduced in the latest Netbeans update? However, I have only seen it for java.awt.Point variables, and I have only been using that type recently.

Did this work correctly in an earlier version?

No / Don't know

Operating System

Win11

JDK

jdk21

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

It seems intermittent... some variables display correct values, other don't. Usually looking at individual fields shows the correct values, whereas the summary line is often wrong. Creating a new Watch seems to give correct values... it is the update of a pre-existing Watch or Variable that shows the wrong value

Are you willing to submit a pull request?

No

@frankvdh frankvdh added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Aug 25, 2024
@matthiasblaesing
Copy link
Contributor

You don't say what that point is and which threads are blocked when you observe this. Trivial reason: You break on $random thread, which also has access to the variable written in parallel by a different (unbreaked) thread. Evaluating the variables does take a non-trivial amout of time, so each invocation potentially observes a different state.

@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) debugger labels Aug 26, 2024
@frankvdh
Copy link
Author

Hi Matthias,
"Point" is java.awt.Point. I am currently only using it as a convenient way to store (X,Y) integer pairs.

This is not a complex multi-threaded app. It happens even when running a single-threaded individual test, so I don't think it's related to variables being written in parallel.

Attached are source files... TracerTest has test cases (some of which fail in various ways... testInnerOuter2 [line 423] succeeds), Tracer is the class I'm trying to debug, others are just supporting classes.
Tracer.zip

A breakpoint at Line 398 exhibits the fault. "curr.p" shows a value of {1, 0} but below it the value of curr.p.x is shown correctly as 2.
image

As you can imagine, this displaying of incorrect values (whatever the reason) makes it very tedious to try and debug the application.

Frank

@matthiasblaesing
Copy link
Contributor

@frankvdh please provide a minimal runnable sample (maven project?). I took your source files, moved them into a maven structure only to then notice, that it is an incomplete set of classes. I.e. the project is not runnable. Given, that the behavior at runtime is the core of the problem, the code is only of limited help.

@frankvdh
Copy link
Author

New minimal project attached.

When I debug the test case, the fault is visible on the second hit of the breakpoint at line 368 of Tracer.java

Tracer.zip
image

@matthiasblaesing
Copy link
Contributor

Thank you for the project, regrettably I can't reproduce. Both the Ubuntu JDK 21 (Linux), and Amazon Corretto 21 (Windows) give consistent output:

image
image

Multiple runs gave the same output when the breakpoint was hit.

What I did was this:

  1. I downloaded the example project
  2. I set a break point in `Tracer.java´, line 368
  3. Run "Debug testInnerOuter2 method" from the test menu:
    image
    4.Wait until breakpoint is hit
  4. Add 4 watches: curr, curr.p, curr.p.x, curr.p.y

The NB Version used was 22. Which JDK did you use for the test?

@frankvdh
Copy link
Author

frankvdh commented Sep 4, 2024 via email

@matthiasblaesing
Copy link
Contributor

@frankvdh there is no "latest JDK". There is one popular JDK implementation project called OpenJDK, which only supplies sources. Then there are multiple vendors (Amazon, Microsoft, Azul, Red Hat, Bellsoft, Oracle, ....) that provide binaries build from this source. But these binaries are also not identical, but contain vendor specific patches.
What is more there are other projects, that retain the classpath from OpenJDK, but implement their own VM (GraalVM, OpenJ9).
So which JDK flavor did you use?

@frankvdh
Copy link
Author

frankvdh commented Sep 5, 2024 via email

@matthiasblaesing
Copy link
Contributor

Tested now with Oracle JDK 21 and GraalVM 21 - both show consistent results. Still not reproducible. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debugger Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) kind:bug Bug report or fix needs:triage Requires attention from one of the committers
Projects
None yet
Development

No branches or pull requests

3 participants