google / pprof

pprof is a tool for visualization and analysis of profiling data
Apache License 2.0
8.03k stars 608 forks source link

"go test ./..." fails when llvm-symbolizer is not available (even if llvm-symbolizer-14 is there) #906

Open aalexand opened 1 month ago

aalexand commented 1 month ago

891 added support for populating function start lines using llvm-symbolizer data. One caveat is that if llvm-symbolizer is not available, the default go test ./... run fails with the error below. In fact, even if llvm-symbolizer is available in its versioned form, such as llvm-symbolizer-14, the test run still fails with the same error.

The workaround right now is to install llvm-symbolizer and then run a command like sudo update-alternatives --install /usr/bin/llvm-symbolizer llvm-symbolizer /usr/bin/llvm-symbolizer-14 100. This command makes the symbolizer available as llvm-symbolizer, which enables pprof to locate it.

Maybe we should make the test skipped if llvm-symbolizer is not available, but also have an option (a flag or environment variable) to disable that skippage so that we set that option in our CI to ensure we forcefully test the start function numbers.

$ go test ./...
?       github.com/google/pprof [no test files]
?       github.com/google/pprof/driver  [no test files]
ok      github.com/google/pprof/fuzz    0.034s
?       github.com/google/pprof/internal/plugin [no test files]
?       github.com/google/pprof/internal/proftest   [no test files]
?       github.com/google/pprof/internal/transport  [no test files]
?       github.com/google/pprof/third_party/svgpan  [no test files]
--- FAIL: TestObjFile (1.77s)
    --- FAIL: TestObjFile/fixed_load_address (1.65s)
        binutils_test.go:379: SourceLine for main: got [{main /tmp/hello.c 3 0 0}]; want [{main /tmp/hello.c 3 0 3}]
    --- FAIL: TestObjFile/simulated_ASLR_address (0.12s)
        binutils_test.go:379: SourceLine for main: got [{main /tmp/hello.c 3 0 0}]; want [{main /tmp/hello.c 3 0 3}]
FAIL
FAIL    github.com/google/pprof/internal/binutils   1.867s
ok      github.com/google/pprof/internal/driver 1.728s
ok      github.com/google/pprof/internal/elfexec    0.092s
ok      github.com/google/pprof/internal/graph  0.125s
ok      github.com/google/pprof/internal/measurement    0.125s
ok      github.com/google/pprof/internal/report 0.921s
ok      github.com/google/pprof/internal/symbolizer 0.097s
ok      github.com/google/pprof/internal/symbolz    0.071s
ok      github.com/google/pprof/profile 0.114s
FAIL
gmarin13 commented 1 month ago

Maybe we should make the test skipped if llvm-symbolizer is not available

It looks like just the function start line is missing. One option is to check everything if llvm-symbolizer is present and ignore the start line if it's missing.

But I agree that we want to force the check in the CI to make sure the code doesn't rot.

shantuo commented 1 month ago

I see #891 updated the fake-llvm-symbolizer to output those start lines but that fake is not used in these failed tests.

aalexand commented 1 month ago

I think not all tests use the fake, intentionally.