meshery / meshery/meshkit

SVG files opened during model/component registration are never closed (fd leak)

Open Beginner friendly
#1,091 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
223
Forks
225
Avg merge
7d 1h
Merged PRs (30d)
1

Description

In `models/registration/svg_helper.go`, `WriteAndReplaceSVGWithFileSystemPath` opens up to 3 files per call via `os.Create` (color, white, complete) and never calls `Close()` on any of them, on either the success or error return path.

This function runs once per model and once per component during registration (`models/registration/register.go` lines 81 and 130), so registering a package with N components leaks roughly 3*(N+1) file descriptors.

Reproduced against `origin/master` (cf39c57): a test that calls the function 50 times and checks `/proc/self/fd` shows the descriptor count grow by 3 per call with no fix, flat with a `defer Close()` added after each `os.Create`.

Will open a PR shortly with the fix + regression test.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in models/registration/svg_helper.go at WriteAndReplaceSVGWithFileSystemPath, then inspect its callers in models/registration/register.go at lines 81 and 130. Reproduce the issue with repeated calls and /proc/self/fd, and verify that the regression test keeps descriptor growth flat on both success and error paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.