Skip to content

Conversation

@Satar07
Copy link

@Satar07 Satar07 commented Dec 20, 2025

Motivation

Currently, ProcMapEntry::parse enforces a strict format where the path must be the last token in the line.

This causes parsing failures when mapped libraries have been updated or deleted, as the kernel appends a (deleted) suffix to the path in /proc/pid/maps (e.g., /usr/lib/libc.so (deleted)).

Because split_whitespace treats the suffix as a separate token, the current logic returns an error for such lines. This causes find_library_path_by_name to fail entirely, preventing uprobes from attaching even if the target library is valid.

Solution

This PR relaxes the parsing logic in ProcMapEntry::parse while maintaining backward compatibility with existing tests:

  1. Lenient for Absolute Paths: If a token starts with /, it is accepted as the path. Any subsequent tokens (specifically the (deleted) suffix) are ignored.
  2. Strict for Invalid Formats: Tokens that do not look like valid paths or special mappings (e.g. garbage strings) still trigger a parse error, ensuring existing tests pass.

Testing

  • Verified that cargo test passes (including strict parsing tests).

Fixes: #1423


This change is Reviewable

@netlify
Copy link

netlify bot commented Dec 20, 2025

Deploy Preview for aya-rs-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 5e7f49d
🔍 Latest deploy log https://app.netlify.com/projects/aya-rs-docs/deploys/694a626479405900084a18f1
😎 Deploy Preview https://deploy-preview-1424--aya-rs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Member

@tamird tamird left a comment

Choose a reason for hiding this comment

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

Hi. This needs a new test.

Please keep the logic is strict (ignoring precisely what is expected).

@Satar07 Satar07 force-pushed the fix/proc-maps-parsing branch 3 times, most recently from 46c3127 to 4ec4657 Compare December 20, 2025 16:27
currently, `procmapentry::parse` enforces a strict format where the
path must be the last token in the line. this causes parsing failures
when mapped files have been deleted, as the kernel appends a
" (deleted)" suffix (e.g. "/usr/lib/libfoo.so (deleted)").

this strictness causes `find_library_path_by_name` to fail entirely
if such lines exist, preventing uprobes from attaching.

this patch relaxes the parsing logic by accepting the first token of
the path field as the valid path if it starts with '/', ignoring
any subsequent tokens like the deleted marker.

Signed-off-by: cyril <multya77@gmail.com>
@Satar07 Satar07 force-pushed the fix/proc-maps-parsing branch from 4ec4657 to 2bf5bb2 Compare December 20, 2025 16:33
@Satar07
Copy link
Author

Satar07 commented Dec 20, 2025

Thanks! I've updated the logic to strictly accept only the (deleted) suffix after an absolute path. Any other trailing tokens will still cause a parse error. I also added a test case to cover this.

@tamird
Copy link
Member

tamird commented Dec 22, 2025

As mentioned in an earlier comment that was perhaps missed: can we do this with less rewriting in the LLM's preferred style?

@Satar07
Copy link
Author

Satar07 commented Dec 22, 2025

Apologies for the noise. To be honest, I ran into this issue while working on an Android eBPF tool and used an LLM to help quickly prototype a fix. I was eager to contribute the solution back upstream but realized I shouldn't have pushed the generated code without refining it first.

I genuinely appreciate the rigorous review process here—it clearly shows why Aya is such a high-quality library.

I'll rework the implementation to address this.

@tamird tamird force-pushed the fix/proc-maps-parsing branch from c60a3b4 to c540831 Compare December 23, 2025 09:31
@tamird
Copy link
Member

tamird commented Dec 23, 2025

@Satar07 I pushed another commit to reduce the diff further. Does this look reasonable to you?

@tamird tamird force-pushed the fix/proc-maps-parsing branch from c540831 to 5e7f49d Compare December 23, 2025 09:35
@Satar07
Copy link
Author

Satar07 commented Dec 23, 2025

That works for me! I appreciate you jumping in to clean this up.

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.

uprobe: find_library_path_by_name fails when /proc/pid/maps contains "(deleted)" suffix

3 participants