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

x/debug/cmd/viewcore: won't find existing executable and won't accept specified executable path #28091

Closed
HouzuoGuo opened this issue Oct 9, 2018 · 5 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@HouzuoGuo
Copy link

What version of Go are you using (go version)?

1.11.1

Does this issue reproduce with the latest release?

The issue is encountered at revision 547453c34fb121ed0dae9624edc8a7a0c1e4e87d.

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/howard/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/howard/gopath"
GOPROXY=""
GORACE=""
GOROOT="/home/howard/go"
GOTMPDIR=""
GOTOOLDIR="/home/howard/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build115617342=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Compile the following code with go build -o sleep:

package main

import "time"

func main() {
        time.Sleep(100 * time.Second)
}

While it executes, capture a core dump with gcore, and then feed it to viewcore, which unfortunately does not find the executable file despite that it exists:

howard@vm ~> viewcore ./core.26015 overview
missing executable "/home/howard/sleep"; consider specifying the --exe flag

By specifying the executable path, viewcore does not parse the CLI flags correctly:

howard@vm ~> viewcore --exe ./sleep ./core.26015 overview
Error: accepts 0 arg(s), received 2
Usage:
...

And it won't help if flags are swapped around:

howard@vm ~> viewcore  ./core.26015 --exe ./sleep overview
missing executable "./sleep"
@gopherbot gopherbot added this to the Unreleased milestone Oct 9, 2018
@ianlancetaylor
Copy link
Contributor

CC @randall77 @hyangah

@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 9, 2018
@hyangah
Copy link
Contributor

hyangah commented Oct 9, 2018

The viewcore requires corefile as the first thing following the command name as show in the usage.

viewcore
Usage:
viewcore <corefile> [flags]
viewcore <corefile> [flags] [command]

The last one is supposed to work. If not, that's a bug. Can anyone post the core file and the sleep binary - assuming there is no sensitive info - here so I can look into it? I don't have linux access right now.

@randall77
Copy link
Contributor

I can reproduce. It looks like there's something different about gcore-generated core dumps.
If I add an explicit crash to the test code, I can process the resulting core with viewcore just fine.

In the gcore core, the mapping for the executable file does not have the executable bit set. Viewcore skips over such mappings when looking for the executable. So it ends up finding no executable, and barfs.

I don't really understand why gcore isn't marking the executable mapping as executable. It clearly is.

We should probably fix viewcore to not depend on the executable bit to filter the candidate executables.

We clearly also need a better error message.

@HouzuoGuo
Copy link
Author

Thanks @hyangah and @randall77 .

Here's an archive of sleep executable and core file.
sleep-and-core.zip

@gopherbot
Copy link

Change https://golang.org/cl/142837 mentions this issue: internal/core: read additional mapping info from the executable

@golang golang locked and limited conversation to collaborators Oct 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants