Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use /proc/self/exe as the last resort for libbfd
Libbfd implementation of Backward had a bug, that it couldn't resolve anything in case symbols were stripped into a separate file. The problem was that an executable path was passed as /proc/self/exe to be able to find symbols even when the original file is deleted from the file system, or is replaced. When symbols are stripped from an executable, libbfd tries to find a <debuglink>.debug file in the same folder, where <debuglink> is a name built into executable file. With /proc/self/exe it was trying to find /proc/self/<debuglink>.debug file, which obviously never exists. The patch makes Backward first try to open the original executable, and only in case of a failure fallback to /proc/self/exe workaround. It is worth mentioning, that it is not enough just to check that the original file is there. There can be *something* by the executable's file path, but not necessarily the original file - it could be replaced. For that the patch compares inode numbers of the file and or /proc/self/exe. If they are equal, files are the same, and it is safe to use the original path. Fallback to /proc/self/exe happens only if the original file is replaced or deleted. The regression was introduced in 1ecbdc6 ("Handle executable being deleted or replaced by directly opening"). Note, that the bug still exists for libdwarf, and probably for other libs too, but it is not so trivial to fix the bug for them. For example, libdwarf does not look for .debug file automatically at all. This is a subject for a separate patch. Closes #160
- Loading branch information