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

Fix infinite loop causing memory leak in GH-1519 #1531

Closed
wants to merge 1 commit into from

Conversation

joshbode
Copy link
Contributor

No description provided.

@joshbode
Copy link
Contributor Author

I don't know the codebase/protocol well enough to know whether we can always expect there to be at least one value in the iterator, or whether we need to have a fallback and a check, e.g.

head = next(iter(results), None)
if head is None:
    break

@@ -450,6 +450,7 @@ async def _browse_next(self, results: Iterable[ua.BrowseResult]) -> List[ua.Refe
params.ContinuationPoints = [head.ContinuationPoint]
params.ReleaseContinuationPoints = False
results = await self.session.browse_next(params)
head = next(iter(results))
Copy link
Member

Choose a reason for hiding this comment

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

yes we should check that next does not return None

@@ -450,6 +450,7 @@ async def _browse_next(self, results: Iterable[ua.BrowseResult]) -> List[ua.Refe
params.ContinuationPoints = [head.ContinuationPoint]
params.ReleaseContinuationPoints = False
results = await self.session.browse_next(params)
head = next(iter(results))
Copy link
Member

Choose a reason for hiding this comment

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

but something else i wrong here. The original code only handled results[0] and this is correct since we only sent one request to server. Now that check is gone...

@@ -450,6 +450,7 @@ async def _browse_next(self, results: Iterable[ua.BrowseResult]) -> List[ua.Refe
params.ContinuationPoints = [head.ContinuationPoint]
params.ReleaseContinuationPoints = False
results = await self.session.browse_next(params)
head = next(iter(results))
Copy link
Member

Choose a reason for hiding this comment

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

I propose we just revert to original code, I do not see anything wrong in it (apart from getting a strange error if result does not contain at least one result., it should but...)

@oroulet
Copy link
Member

oroulet commented Dec 18, 2023

I reverted change in that other MR: #1534.
Thank for you help @joshbode !

@oroulet oroulet closed this Dec 18, 2023
@joshbode
Copy link
Contributor Author

Sounds good, @oroulet :)

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