Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This fixes a classic TOCTOU. The problem is that if `pid` exits between the exists() check and read_symlink() we will eat a ENOENT exception. Fix by checking result of read_symlink() operation itself. Discovered in a flakey test run in another PR: [ FAILED ] builtin.func_uprobe_elf_symtable Command: /home/runner/work/bpftrace/bpftrace/build-ci/src/bpftrace -e 'uprobe:./testprogs/uprobe_symres_exited_process:test { print(func); exit(); }' Unclean exit code: -6 Output: Attaching 1 probe...\n__BPFTRACE_NOTIFY_PROBES_ATTACHED\nterminate called after throwing an instance of 'std::filesystem::__cxx11::filesystem_error'\n what(): filesystem error: read_symlink: No such file or directory [/proc/13255/exe]\n
- Loading branch information