Files
packages/extra/abseil-cpp/abseil-cpp-20260107.1-symbolize-proc-maps-fallback.patch
2026-03-21 12:43:00 -05:00

35 lines
1.5 KiB
Diff

diff --git a/absl/debugging/symbolize_elf.inc b/absl/debugging/symbolize_elf.inc
index 0317bbc..e4a5060 100644
--- a/absl/debugging/symbolize_elf.inc
+++ b/absl/debugging/symbolize_elf.inc
@@ -1086,17 +1086,24 @@ static ABSL_ATTRIBUTE_NOINLINE bool ReadAddrMap(
void *arg, void *tmp_buf, size_t tmp_buf_size) {
// Use /proc/self/task/<pid>/maps instead of /proc/self/maps. The latter
// requires kernel to stop all threads, and is significantly slower when there
- // are 1000s of threads.
+ // are 1000s of threads. Some container procfs implementations do not expose
+ // per-thread maps files, so fall back to /proc/self/maps when needed.
char maps_path[80];
snprintf(maps_path, sizeof(maps_path), "/proc/self/task/%d/maps", getpid());
int maps_fd;
NO_INTR(maps_fd = OpenReadOnlyWithHighFD(maps_path));
- FileDescriptor wrapped_maps_fd(maps_fd);
- if (wrapped_maps_fd.get() < 0) {
- ABSL_RAW_LOG(WARNING, "%s: errno=%d", maps_path, errno);
- return false;
+ if (maps_fd < 0) {
+ const int task_maps_errno = errno;
+ NO_INTR(maps_fd = OpenReadOnlyWithHighFD("/proc/self/maps"));
+ if (maps_fd < 0) {
+ const int self_maps_errno = errno;
+ ABSL_RAW_LOG(WARNING, "%s: errno=%d; /proc/self/maps: errno=%d",
+ maps_path, task_maps_errno, self_maps_errno);
+ return false;
+ }
}
+ FileDescriptor wrapped_maps_fd(maps_fd);
// Iterate over maps and look for the map containing the pc. Then
// look into the symbol tables inside.