Skip to content

fix(hooks): prevent panic from loop variable capture in concurrent execution#445

Merged
cmainas merged 1 commit intourunc-dev:main-pr445from
hemang1404:fix-concurrent-hooks-panic-418
Feb 12, 2026
Merged

fix(hooks): prevent panic from loop variable capture in concurrent execution#445
cmainas merged 1 commit intourunc-dev:main-pr445from
hemang1404:fix-concurrent-hooks-panic-418

Conversation

@ishaanxgupta
Copy link

Description

This PR fixes a loop variable capture bug in executeHooksConcurrently() that could cause panics and incorrect logging when hooks are executed concurrently.
Panic Prevention: Eliminates panic when i == len(hooks) after loop completes

Related issues

How was this tested?

Confirmed the captured parameter h is used consistently in the goroutine
Checked that no other instances of this pattern exist in the function

LLM usage

N/A

Checklist

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).
  • If LLMs were used: I have read the llm policy.

collaborated with @hemang1404

@netlify
Copy link

netlify bot commented Feb 4, 2026

Deploy Preview for urunc ready!

Name Link
🔨 Latest commit f1571ef
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/698d76740a531f0008837a6c
😎 Deploy Preview https://deploy-preview-445--urunc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ishaanxgupta
Copy link
Author

@cmainas please have a look

@hemang1404 hemang1404 force-pushed the fix-concurrent-hooks-panic-418 branch 2 times, most recently from 0854c8d to 0957257 Compare February 5, 2026 15:52
@cmainas
Copy link
Contributor

cmainas commented Feb 6, 2026

Hello @ishaanxgupta ,

the changes look good, but a rebase over the main branch is required.

@hemang1404 hemang1404 force-pushed the fix-concurrent-hooks-panic-418 branch from 0957257 to af3ce32 Compare February 6, 2026 09:59
@ishaanxgupta
Copy link
Author

@cmainas done

@cmainas
Copy link
Contributor

cmainas commented Feb 6, 2026

I see another user pushed here @hemang1404 . I do not know how that happened but:

@hemang1404 hemang1404 force-pushed the fix-concurrent-hooks-panic-418 branch 3 times, most recently from 7cc0779 to 047662d Compare February 7, 2026 22:19
@cmainas
Copy link
Contributor

cmainas commented Feb 9, 2026

Hello @ishaanxgupta ,

please rebase over main so we can merge this.

@hemang1404 hemang1404 force-pushed the fix-concurrent-hooks-panic-418 branch from 047662d to 623e73f Compare February 11, 2026 21:09
@ishaanxgupta
Copy link
Author

hi @cmainas done with the rebase

Fix panic from accessing hooks[i] in async execution after loop.

Use captured parameter h instead.

Fixes: urunc-dev#418

Co-authored-by: hemang1404 <hemangsharrma@gmail.com>
Signed-off-by: ishaanxgupta <ishaankone@gmail.com>
@hemang1404 hemang1404 force-pushed the fix-concurrent-hooks-panic-418 branch from 623e73f to f1571ef Compare February 12, 2026 06:42
@urunc-bot urunc-bot bot changed the base branch from main to main-pr445 February 12, 2026 08:07
Copy link
Contributor

@cmainas cmainas left a comment

Choose a reason for hiding this comment

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

Thank you @ishaanxgupta and @hemang1404 for the fix.

@cmainas cmainas merged commit 4f21308 into urunc-dev:main-pr445 Feb 12, 2026
33 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 12, 2026
Fix panic from accessing hooks[i] in async execution after loop.

Use captured parameter h instead.

Fixes: #418

PR: #445
Co-authored-by: hemang1404 <hemangsharrma@gmail.com>
Signed-off-by: ishaanxgupta <ishaankone@gmail.com>
Reviewed-by: Charalampos Mainas <cmainas@nubificus.co.uk>
Approved-by: Charalampos Mainas <cmainas@nubificus.co.uk>
urunc-bot bot pushed a commit that referenced this pull request Feb 12, 2026
Fix panic from accessing hooks[i] in async execution after loop.

Use captured parameter h instead.

Fixes: #418

PR: #445
Co-authored-by: hemang1404 <hemangsharrma@gmail.com>
Signed-off-by: ishaanxgupta <ishaankone@gmail.com>
Reviewed-by: Charalampos Mainas <cmainas@nubificus.co.uk>
Approved-by: Charalampos Mainas <cmainas@nubificus.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants