Skip to content

Fix re-adding a node to EventsCBGExecutor after remove_node - #3464

Open
suryakanths wants to merge 1 commit into
ros2:rollingfrom
suryakanths:fix-events-cbg-readd-node
Open

suryakanths wants to merge 1 commit into
ros2:rollingfrom
suryakanths:fix-events-cbg-readd-node

Conversation

@suryakanths

Copy link
Copy Markdown

Description

Removing a node and re-adding it before the executor syncs its callback groups left the node's entities unregistered. remove_node() now drops the node's callback group entries immediately, so the next sync registers them again. Add a regression test for remove and re-add inside one callback.

Fixes #3418

Is this user-facing behavior change?

Yes. A node that is removed and re-added to an EventsCBGExecutor in quick succession keeps running its timers and subscriptions.

Did you use Generative AI?

NO

Additional Information

None

Fixes ros2#3418.

Signed-off-by: suryakanth <suryakanth@anscer.com>
@suryakanths
suryakanths force-pushed the fix-events-cbg-readd-node branch from 910fc85 to 3e2ccd8 Compare December 1, 2026 18:41
@jmachowinski

Copy link
Copy Markdown
Collaborator

I'm pretty sure this patch introduces a use after free for events being processed while remove_node is called.

I am also currently working on a solution to this.

@suryakanths

Copy link
Copy Markdown
Author

@jmachowinski Thanks for the review. Can you tell me which object is freed, and in which sequence? I did not find the path by reading the code.

I did find a related problem in my patch. A remove and re-add creates a second scheduler handle for the same callback group. The old handle can still be executing, so a mutually exclusive group could run concurrently. I have not reproduced this yet.

Since you are working on a solution, I am happy to close this PR in favor of yours. You are welcome to use the regression test.

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.

removing and immediately re-adding a node to the EventsCBGExecutor leaves its entities unregistered

3 participants