Skip to content

fix futexctn tool for symbol resolution and infinite loop#5496

Open
dubeyabhishek wants to merge 2 commits intoiovisor:masterfrom
dubeyabhishek:master
Open

fix futexctn tool for symbol resolution and infinite loop#5496
dubeyabhishek wants to merge 2 commits intoiovisor:masterfrom
dubeyabhishek:master

Conversation

@dubeyabhishek
Copy link
Copy Markdown

Please find detailed description of "stack symbol resolution" and "infinite loop behavior in map cleanup" in corresponding commit message.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to fix futexctn issues around user-space stack symbol resolution (especially for short-lived processes) and prevent an infinite loop during histogram map cleanup.

Changes:

  • Updated syms_cache__get_syms() behavior to try to refresh cached symbols on cache hits.
  • Changed futexctn histogram cleanup to snapshot keys before deleting them to avoid looping.
  • Added a symbol “preload” pass intended to populate the symbol cache ahead of stack printing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
libbpf-tools/trace_helpers.c Modifies symbol cache lookup/refresh behavior in syms_cache__get_syms().
libbpf-tools/futexctn.c Adds symbol-cache preloading and changes map cleanup to delete snapshotted keys.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Abhishek Dubey added 2 commits April 12, 2026 12:38
Preload symbol cache entries in the wait loop of futexctn to handle
processes that exit before print_stack is invoked.

Previously, syms_cache__get_syms was called lazily at print time.
For short-lived processes that exit before Ctrl-C is delivered,
/proc/<tgid>/maps no longer exists at print time, causing
syms__load_pid to return NULL and stack traces to show
"failed to get syms" or "[unknown]" for all frames.

Fix this by preloading the symbol cache in wait loop throughout
the collection interval. This ensures symbols are loaded while
the traced process is still alive, and remain available in the
cache for symbol resolution even after the process has exited.

Signed-off-by: Abhishek Dubey <adubey@linux.ibm.com>
Snapshot hists map keys before cleanup to bound the number of
entries to delete.

The cleanup loop iterated the hists map while the BPF program
continued inserting new entries in parallel. Passing a deleted
key back to bpf_map_get_next_key caused the kernel to return
the first available key, which could be a newly inserted entry,
making the loop non-terminating.

Fix this by snapshotting all existing keys into a heap-allocated
array before deletion. The cleanup loop then deletes only the
finite set of snapshotted keys, leaving any new entries inserted
by BPF during cleanup intact for the next interval.

Signed-off-by: Abhishek Dubey <adubey@linux.ibm.com>
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.

2 participants