Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix attaching to multiple USDT probes using the same wildcard #2456

Merged
merged 1 commit into from
Jan 2, 2023
Merged

Fix attaching to multiple USDT probes using the same wildcard #2456

merged 1 commit into from
Jan 2, 2023

Conversation

jonas-kaufmann
Copy link
Contributor

@jonas-kaufmann jonas-kaufmann commented Dec 13, 2022

Hi,
this is my first pull request in a public repository. Let me know what I can improve :)

Short description of the issue:
Attaching to multiple USDT probes with different number of locations by the same wildcard can produce the error 'code not generated for probe'. The reason is that a single AttachPoint has multiple matching probes in this case but we only store the USDT information for a single probe in AttachPoint. Later, the number of locations from the USDT information stored in AttachPoint is used to look up the generated code for every probe to attach to, which can differ between the USDT probes and cause the above mentioned error.

Checklist
  • Language changes are updated in man/adoc/bpftrace.adoc and if needed in docs/reference_guide.md
  • User-visible and non-trivial changes updated in CHANGELOG.md
  • The new behaviour is covered by tests

Copy link
Contributor

@viktormalik viktormalik left a comment

Choose a reason for hiding this comment

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

Hi, thanks for the PR!

I've couple of comments in the code, plus one general question: what will happen if we don't give a wildcard but still attach to a probe with multiple locations (usdt:./testprogs/usdt_multiple_locations:tracetest:testprobe)?

Also I'd prefer all the commits squashed into one since the changes (in the code and in the tests) are coupled together.

tests/runtime/usdt Show resolved Hide resolved
tests/runtime/usdt Outdated Show resolved Hide resolved
src/bpftrace.cpp Outdated Show resolved Hide resolved
Attaching to multiple USDT probes with different number of locations by
the same wildcard can produce the error 'code not generated for probe'.
The reason is that a single AttachPoint has multiple matching probes in
this case but we only store the USDT information for a single probe in
AttachPoint. Later, the number of locations from the USDT information
stored in AttachPoint is used to look up the generated code for every
probe to attach to, which can differ between the USDT probes and cause
the above mentioned error.

Add test for attaching with single wildcard to multiple USDT probes with different number of locations

USDT test multiple files: update expected number of attached probes

Update CHANGELOG
Fix attaching to multiple USDT probes using the same wildcard
@jonas-kaufmann
Copy link
Contributor Author

I've couple of comments in the code, plus one general question: what will happen if we don't give a wildcard but still attach to a probe with multiple locations (usdt:./testprogs/usdt_multiple_locations:tracetest:testprobe)?

In that case everything works as expected. An AttachPoint is created for usdt:./testprogs/usdt_multiple_locations:tracetest:testprobe and the USDT information stored in it is correct meaning we use the correct number of locations in https://github.com/iovisor/bpftrace/blob/517fb1a05012ae47663ae5a30c166e4f57d6e576/src/bpftrace.cpp#L273-L281

The issue I am fixing only arises when a single AttachPoint refers to multiple USDT probes.

@viktormalik
Copy link
Contributor

In that case everything works as expected. An AttachPoint is created for usdt:./testprogs/usdt_multiple_locations:tracetest:testprobe and the USDT information stored in it is correct meaning we use the correct number of locations in

Right, thanks for confirmation!

@viktormalik viktormalik merged commit 6236ac7 into bpftrace:master Jan 2, 2023
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