镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

ffi: free libuv error message on failed dlopen - #67007

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:ffi-dlopen-failed-memory-leak
Open

trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:ffi-dlopen-failed-memory-leak

Conversation

@trivikr

@trivikr trivikr commented Oct 25, 2026

Copy link
Copy Markdown
Member

Fixes: #67006

uv_dlopen() allocates an error message on failure, and only uv_dlclose() frees it. DynamicLibrary::Close() skips uv_dlclose() when the handle is null, so every failed ffi.dlopen() leaked about 1 KB. This calls uv_dlclose() on the failure path, as DLib::Open() does in node_binding.cc.

There's no regression test because a JS test can't reliably catch a leak this size.


Assisted-by: claude:opus-5.5

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/ffi

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Oct 25, 2026
When uv_dlopen() fails, the error message it allocates is only
released by uv_dlclose(). DynamicLibrary::Close() skips uv_dlclose()
when the handle is null, so each failed ffi.dlopen() leaked the
message. Call uv_dlclose() on the failure path, as DLib::Open() does.

Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
Assisted-by: claude:opus-5.5
@trivikr
trivikr force-pushed the ffi-dlopen-failed-memory-leak branch from 81fd47c to 4719023 Compare October 25, 2026 22:21
@trivikr trivikr changed the title src: free libuv error message on failed ffi dlopen ffi: free libuv error message on failed dlopen Oct 25, 2026
@trivikr trivikr added ffi Issues and PRs related to experimental Foreign Function Interface support. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Oct 25, 2026
@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.59%. Comparing base (a2cd8aa) to head (4719023).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67007      +/-   ##
==========================================
- Coverage   90.61%   90.59%   -0.02%     
==========================================
  Files         797      797              
  Lines      278227   278228       +1     
  Branches    53486    53483       -3     
==========================================
- Hits       252103   252064      -39     
- Misses      16499    16550      +51     
+ Partials     9625     9614      -11     
Files with missing lines Coverage Δ
src/node_ffi.cc 72.81% <100.00%> (+0.03%) ⬆️

... and 29 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@daeyeon daeyeon added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Oct 26, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 26, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ffi: failed dlopen() leaks the libuv error message

4 participants