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

pkg/maps: Skip more pseudo-paths and anonymous mappings #266

Merged
merged 1 commit into from Mar 2, 2022

Conversation

mrueg
Copy link
Contributor

@mrueg mrueg commented Mar 2, 2022

This should prevent trying to access the root symlink because the m.File is empty.

level=warn ts=2022-03-02T15:50:14.508461455Z caller=maps.go:102 msg="failed to read obj build ID" obj=/proc/12497/root err="failed to open elf: read /proc/12497/root: is a directory"

(Hopefully)
Fixes: #82

@mrueg mrueg changed the title pkg/maps: Skip if file is empty pkg/maps: Skip if file var is empty Mar 2, 2022
Copy link
Member

@kakkoyun kakkoyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Funny enough, I did a similar change on another WIP PR.

@mrueg
Copy link
Contributor Author

mrueg commented Mar 2, 2022

Ideally there should be a check for the existence of the file, as there are more possible pseudopaths (it might be cheaper to filter them out first).

See man proc

There are additional helpful pseudo-paths:

              [stack]
                     The initial process's (also known as the main
                     thread's) stack.

              [stack:<tid>] (from Linux 3.4 to 4.4)
                     A thread's stack (where the <tid> is a thread ID).
                     It corresponds to the /proc/[pid]/task/[tid]/ path.
                     This field was removed in Linux 4.5, since
                     providing this information for a process with large
                     numbers of threads is expensive.

              [vdso] The virtual dynamically linked shared object.  See
                     [vdso(7)](https://man7.org/linux/man-pages/man7/vdso.7.html).

              [heap] The process's heap.

              If the pathname field is blank, this is an anonymous
              mapping as obtained via [mmap(2)](https://man7.org/linux/man-pages/man2/mmap.2.html).  There is no easy way to
              coordinate this back to a process's source, short of
              running it through [gdb(1)](https://man7.org/linux/man-pages/man1/gdb.1.html), [strace(1)](https://man7.org/linux/man-pages/man1/strace.1.html), or similar.

@kakkoyun
Copy link
Member

kakkoyun commented Mar 2, 2022

Yes, happy to accept contributions to improve things properly. We can even use this PR.

@mrueg mrueg changed the title pkg/maps: Skip if file var is empty pkg/maps: Skip more pseudo-paths and anonymous mappings Mar 2, 2022
@mrueg
Copy link
Contributor Author

mrueg commented Mar 2, 2022

@kakkoyun sounds good, I added the other pseudo paths as well to reduce misleading log message.

Copy link
Member

@kakkoyun kakkoyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kakkoyun kakkoyun merged commit 1f29a22 into parca-dev:main Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check symlink when trying to fetch debuginfo
2 participants