Skip to content

Fix segfault caused double erase from child_pid rb tree #2554

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

Merged
merged 1 commit into from
Feb 27, 2025

Conversation

lukaszwojciechowski
Copy link
Contributor

In a situation when a child was timed out, but not yet processed, the thread is THREAD_CHILD_TIMEOUT type and remains on ready queue. If it gets terminated in this state, it needs to be removed from rb tree child_pid and transitioned to THREAD_CHILD_TERMINATED, but without additional moving it to ready queue as it is already there.

The erase from child_pid tree is required to clean up pid from not terminated childs tree, but it needs to be done exactly once as rb tree implementation is not guarded against double removal. Erasing or adding same element multiple times, leads to malformed red-black tree and segmentation faults.

This patch removes double erase in described scenario.

Might fix #2548

In a situation when a child was timed out, but not yet processed,
the thread is THREAD_CHILD_TIMEOUT type and remains on ready queue.
If it gets terminated in this state, it needs to be removed
from rb tree child_pid and transitioned to THREAD_CHILD_TERMINATED,
but without additional moving it to ready queue as it is already there.

The erase from child_pid tree is required to clean up pid from not
terminated childs tree, but it needs to be done exactly once as rb tree
implementation is not guarded against double removal. Erasing or adding
same element multiple times, leads to malformed red-black tree and
segmentation faults.

This patch removes double erase in described scenario.

Signed-off-by: Lukasz Wojciechowski <[email protected]>
@lukaszwojciechowski
Copy link
Contributor Author

The previous erase was done 9 lines above in line 2204

@pqarmitage pqarmitage merged commit d178d93 into acassen:master Feb 27, 2025
10 checks passed
@pqarmitage
Copy link
Collaborator

@lukaszwojciechowski Thank you very much for identifying this issue and providing the patch.

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.

Segv on rbtree
2 participants