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

Missing local variables in thread dump #215

Closed
thurka opened this issue Jul 15, 2020 · 0 comments
Closed

Missing local variables in thread dump #215

thurka opened this issue Jul 15, 2020 · 0 comments
Assignees
Labels

Comments

@thurka
Copy link
Member

thurka commented Jul 15, 2020

Describe the bug
Not all local variable are displayed in thread dump extracted from a heap dump.

To Reproduce
Take a heap dump from following program:

package javaapplication2;

import java.io.PrintStream;

public class JavaApplication2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        print1(System.out);
    }

    private static void print1(PrintStream out) {
        print2(out);
    }

    private static void print2(PrintStream out) {
        print3(out);
    }

    private static void print3(PrintStream out) {
        for (int i = 0; i < 100000; i++) {
            out.println("Hello World");
        }
    }
    
}

Expected behavior
Currently the thread dump with local variables looks like this:

"main" prio=5 tid=1 RUNNABLE
    at java.io.FileOutputStream.writeBytes(Native Method)
    at java.io.FileOutputStream.write(FileOutputStream.java:326)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
       local variable: java.io.BufferedOutputStream#1
    at java.io.PrintStream.write(PrintStream.java:482)
    at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
       local variable: sun.nio.cs.StreamEncoder#1
    at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
    at sun.nio.cs.StreamEncoder.flushBuffer(StreamEncoder.java:104)
       local variable: java.io.OutputStreamWriter#1
    at java.io.OutputStreamWriter.flushBuffer(OutputStreamWriter.java:185)
    at java.io.PrintStream.write(PrintStream.java:527)
       local variable: java.lang.String#12
    at java.io.PrintStream.print(PrintStream.java:669)
    at java.io.PrintStream.println(PrintStream.java:806)
    at javaapplication2.JavaApplication2.print3(JavaApplication2.java:25)
    at javaapplication2.JavaApplication2.print2(JavaApplication2.java:20)
    at javaapplication2.JavaApplication2.print1(JavaApplication2.java:16)
       local variable: java.io.PrintStream#1
    at javaapplication2.JavaApplication2.main(JavaApplication2.java:12)
       local variable: java.lang.String[]#1

JavaApplication2.print2() and JavaApplication2.print3() are missing local variable: java.io.PrintStream#1

@thurka thurka self-assigned this Jul 15, 2020
@thurka thurka added the bug label Jul 15, 2020
thurka added a commit that referenced this issue Aug 3, 2020
…ow returns Collection not just one GCRoot instance; Heap.getGCRoots() returns all GCRoots including duplicates
@thurka thurka closed this as completed Aug 6, 2020
thurka added a commit that referenced this issue Aug 6, 2020
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

1 participant