janestreet / janestreet/magic-trace

Failure to read symbols inside docker-container due to broken /proc/pid/exe link

Open
#307 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
OCaml
Stars
6.3k
Forks
209
PR merge metrics
No merged PRs in 30d

Description

Hi. I encountered this problem while trying to trace binary inside docker-container.
The problem manifests as rather misleading
```
Cannot select a snapshot symbol because magic-trace can't find that executable's symbol table. Was it built without debug info, or with debug info magic-trace doesn't understand?
```
message which doesn't indicate failure to open the executable but strace helped here to find the root cause as running the binary outside of container worked well.

The reason is that `/proc//exe` contains a path used to launch the process _inside_ the container which means this path refers to directories _inside_ the container. This symlink is not valid outside of the container

I believe the problem can be fixed by skipping `Core_unix.readlink` here https://github.com/janestreet/magic-trace/blob/7ac635e41438248c3a3348c039dae00854f38342/src/trace.ml#L722 and just directly read the contents of the `/proc//exe`.

Contributor guide

Open the contributing guide

Research direction

Start in src/trace.ml around line 722 and inspect how Core_unix.readlink handles /proc//exe. Reproduce the container-versus-host behavior if possible, then verify that magic-trace can locate the executable and its symbols without the misleading error. A regression test should cover the affected executable lookup if the repository has a suitable test entry point.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, ocaml
Domain
devtools, operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.