Open ajwerner opened 3 years ago
This patch seems to fix it but I wouldn't really know how we'd want to test it:
diff --git a/internal/core/process.go b/internal/core/process.go
index d4da13e..944380e 100644
--- a/internal/core/process.go
+++ b/internal/core/process.go
@@ -512,14 +512,23 @@ func (p *Process) openMappedFile(fname string, m *Mapping) (*os.File, error) {
isMainExe = true
}
- if !isMainExe {
- backing.f, backing.err = os.Open(filepath.Join(p.base, fname))
- } else { // keep main executable in p.mainExecName
- p.mainExecName = fname
- if p.exe != nil {
- backing.f, backing.err = p.exe, nil
- } else {
- backing.f, backing.err = os.Open(filepath.Join(p.base, fname))
+ candidates := []string{fname}
+ if strings.HasSuffix(fname, "(deleted)") {
+ candidates = append(candidates, strings.TrimSuffix(fname, " (deleted)"))
+ }
+ for _, n := range candidates {
+ if !isMainExe {
+ backing.f, backing.err = os.Open(filepath.Join(p.base, n))
+ } else { // keep main executable in p.mainExecName
+ p.mainExecName = fname
+ if p.exe != nil {
+ backing.f, backing.err = p.exe, nil
+ } else {
+ backing.f, backing.err = os.Open(filepath.Join(p.base, fname))
+ }
+ }
+ if backing.err == nil {
+ break
}
}
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
When linux dynamically links shared libraries, it seems that sometimes something involving hugetlb pages I don't understand leads to the shared library being mapped in the process to a file marked as deleted. This leads to entries in
/proc/$pid/maps
tht looks like this:I think this has something to do with the link process copying the so to the
hugetlb
fs and then deleting it. In fact, using older versions of gdb and linux, the path with the(deleted)
annotation doesn't seem to correspond to the path to the actual lib. I can live with using more modern tools than 16.04 so I'm not going to make noise about that.What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
No errors.
What did you see instead?