Skip to content

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

Open
ishaanxgupta wants to merge 1 commit intourunc-dev:mainfrom
hemang1404:fix-concurrent-hooks-panic-418
Open

fix(hooks): prevent panic from loop variable capture in concurrent execution#445
ishaanxgupta wants to merge 1 commit intourunc-dev:mainfrom
hemang1404:fix-concurrent-hooks-panic-418

Conversation

@ishaanxgupta
Copy link
Contributor

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 2c8a260
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/69865b51db9923000853ca2a
😎 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
Contributor 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
Contributor 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:

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

Use captured parameter h instead.

Fixes: urunc-dev#418

Co-authored-by: hemang1404 <[email protected]>
Signed-off-by: Ishaan Gupta <[email protected]>
@hemang1404 hemang1404 force-pushed the fix-concurrent-hooks-panic-418 branch from af3ce32 to 2c8a260 Compare February 6, 2026 21:21
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.

Concurrent hooks can panic due to loop variable capture

3 participants