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

Avoid race condition that could result in NPE #118

Merged
merged 1 commit into from
Nov 11, 2020

Conversation

hannahhoward
Copy link
Collaborator

@hannahhoward hannahhoward commented Nov 11, 2020

Goals

When the same custom data store is used on two seperate requests on the requestor, an NPE can occur in a specific case:

  1. When the responder receives ExtensionDeDupByKey, it sets up a specific link tracking de-deduplication list for the first request
  2. When the second request is received, it reuses the same link tracking de-duplication list.
  3. If the first request finishes before the second request sends a single link, the specific link tracking list will get cleaned up because the check is simply whether the list has been cleared of all links, which given a finished request and a request that has not started traversing, will be the case.
  4. When the second request attempts to use the link tracking list, it will get an NPE

Implementation

Change the check for cleanup of the link tracking list to be an iteration of all deduplicated requests to confirm that NO requests reference this particular de-duplication list, rather than a check of whether the list itself is empty.

Copy link

@arajasek arajasek left a comment

Choose a reason for hiding this comment

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

Makes sense to me!

@hannahhoward hannahhoward merged commit 5c4f657 into master Nov 11, 2020
@aschmahmann aschmahmann mentioned this pull request Feb 18, 2021
73 tasks
@mvdan mvdan deleted the fix/npe-in-link-tracker branch December 15, 2021 14:16
marten-seemann pushed a commit that referenced this pull request Mar 2, 2023
* feat(cidlists): create cidlists interface

* feat(cidlists): integrate into data transfer

integrate cid lists as a migraiton to replace the previous cidlist stored in the state

* fix(test): cleanup logic

use different tempdirs per peer, don't delete files for received cids lists

* style(lint): clean up imports

* fix(cidlists): address PR comments
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