Skip to content

fix(core): prevent timer/ticker leaks; use unsafe.Add for pointer arithmetic#9486

Merged
mangalaman93 merged 1 commit intodgraph-io:mainfrom
eileenaaa:fix/timer-ticker-leaks-and-unsafe-add
Aug 19, 2025
Merged

fix(core): prevent timer/ticker leaks; use unsafe.Add for pointer arithmetic#9486
mangalaman93 merged 1 commit intodgraph-io:mainfrom
eileenaaa:fix/timer-ticker-leaks-and-unsafe-add

Conversation

@eileenaaa
Copy link
Copy Markdown
Contributor

@eileenaaa eileenaaa commented Aug 19, 2025

Description

This PR improves runtime safety and resource handling:

  • Timer: replaced time.After(...) with time.NewTimer(...) and ensured timer.Stop() is always called to avoid hidden leaks in loops.
  • Ticker: added ticker.Stop() and refactored time.Tick(...) usage to use time.NewTicker for proper lifecycle management.
  • Unsafe pointer: switched from unsafe.Pointer + uintptr(offset) to unsafe.Add(...) for clearer and more consistent pointer arithmetic.

These changes make timer/ticker usage safer in long-running goroutines and align pointer operations with modern Go practices.

Checklist

  • Code compiles correctly and linting passes locally
  • For all code changes, an entry added to the CHANGELOG.md file describing and linking to
    this PR
  • Tests added for new functionality, or regression tests for bug fixes added as applicable

@eileenaaa eileenaaa requested a review from a team August 19, 2025 02:28
@mangalaman93 mangalaman93 merged commit f3cda77 into dgraph-io:main Aug 19, 2025
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants