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

v8: only remove prefix when mapping is removed #45

Closed
wants to merge 1 commit into from
Closed

Conversation

Gandem
Copy link
Member

@Gandem Gandem commented Jul 18, 2024

Fix unwinding for JIT code in NodeJS, when SynchronizeMappings is called multiple times for the same process.

If the first frames being unwinded for a new NodeJS PID are JIT frames, we're going to both:

  • report the PID for processing as it's a new PID
  • fail to find the mapping for the PC and report the PID for processing again

If the agent has already treated PID processing for the PID start, it will re-trigger PID processing for the unwinding failure, hence call SynchronizeMappings() twice for the same NodeJS PID with the same mappings.

This in turn, will trigger the bug explained in the commit description below: 707fc7b

@Gandem Gandem force-pushed the nayef/node-fix branch 2 times, most recently from 55d4105 to 707fc7b Compare July 19, 2024 10:40
@Gandem Gandem changed the title test v8: only remove prefix when mapping is removed Jul 19, 2024
@Gandem Gandem force-pushed the nayef/node-fix branch 3 times, most recently from 62ff6c4 to e1227c2 Compare July 19, 2024 12:00
prior to this change we were tracking generation number (i.e.
count of SynchronizeMappings call where the object was found) for
both mappings and prefixes.

if the mapping did not change, we would not re-calculate prefixes
for the mapping, hence we would not increase the generation of the
prefix object.

as such, we would end up cleaning the prefix on the second call of
SynchronizeMappings (if mappings did not change), removing the prefix
from the ebpf map, and making unwinding fail for PC in the JIT area.

to fix this, we only track the generation for mappings. when mappings
are removed, we computed all the prefixes associated to those mappings
and we remove them. this should be safe because different mappings
should have different prefixes.
@Gandem Gandem closed this Jul 19, 2024
nsavoire pushed a commit that referenced this pull request Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant