Skip to content

pmfind / libpcp_web: fix crashes, hang, and fix pending_timer_init#2559

Open
kurik wants to merge 1 commit intoperformancecopilot:mainfrom
kurik:pmfind2
Open

pmfind / libpcp_web: fix crashes, hang, and fix pending_timer_init#2559
kurik wants to merge 1 commit intoperformancecopilot:mainfrom
kurik:pmfind2

Conversation

@kurik
Copy link
Copy Markdown
Contributor

@kurik kurik commented Apr 9, 2026

This is a followup of #2555 resp. #2557, fixing a memory issue introduced in #2555 as well as some orthogonal issues found by qa/{1985,1986,1998}.

What has been done

pmfind (source.c): dictDelete before source_release on remove path; remove pmfind contexts dict entry before bulk release; uv_stop after discovery; call pmWebGroupClose before uv_loop_close, uv_close bootstrap timer, and drain uv_run.

webgroup.c: parse context id before on_done and deref via dict lookup so on_done/pmWebGroupDestroy cannot leave a stale cp; defer free(webgroups) until uv_close callbacks complete for embedded timer and async.

libpcp_web: remove context from pending_timer_init queue before free. Avoid use-after-free when webgroup_async_cb runs after synchronous destroy.

Testing

The main testing has been performed on RHEL-10 and Fedora-43. Due to unavailability of Debian/Ubuntu environment at the moment to me, I left the check on these platforms on the CI pipeline, especially checking results of qa/{1985,1986,1998}. All seems to be good to me.

pmfind (source.c): dictDelete before source_release on remove path; remove
pmfind contexts dict entry before bulk release; uv_stop after discovery;
call pmWebGroupClose before uv_loop_close, uv_close bootstrap timer, and
drain uv_run.

webgroup.c: parse context id before on_done and deref via dict lookup so
on_done/pmWebGroupDestroy cannot leave a stale cp; defer free(webgroups)
until uv_close callbacks complete for embedded timer and async.

libpcp_web: remove context from pending_timer_init queue before free.
Avoid use-after-free when webgroup_async_cb runs after synchronous destroy.
@kurik kurik changed the title DO NOT MERGE YET: pmfind / libpcp_web: fix crashes, hang, and Valgrind UAF in discovery pmfind / libpcp_web: fix crashes, hang, and fix pending_timer_init Apr 10, 2026
@kurik
Copy link
Copy Markdown
Contributor Author

kurik commented Apr 10, 2026

@natoscott I finished the work on this (failing 1985, 1986, 1998 tests after #2555). Can you please review, once you have some time?

@kurik kurik requested a review from natoscott April 10, 2026 14:24
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.

1 participant