oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.35k stars 2.78k forks source link

Fix memory leak in napi_threadsafe_function #15289

Open 190n opened 1 day ago

190n commented 1 day ago

What does this PR do?

Previously napi_threadsafe_function wouldn't free the memory for its channel when it was freed. Now it does. This manifested, for instance, as a leak of 8 bytes per Prisma query.

Fixes #14664 Fixes #12977 Fixes #6599

How did you verify your code works?

I added a memory leak test to prisma.test.ts.

robobun commented 1 day ago

:x: @190n, your commit 0b4d2bd0ed75e4f9900b41505818deb2978dd61a has 10 failures in #6566:

  • test/integration/next-pages/test/dev-server.test.ts - 1 failing on 🐧 3.20 x64
  • test/integration/next-pages/test/dev-server.test.ts - 1 failing on 🐧 3.20 x64-baseline
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 3.20 x64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 3.20 x64-baseline
  • test/v8/v8.test.ts - 22 failing on 🐧 3.20 aarch64
  • test/v8/v8.test.ts - 22 failing on 🐧 3.20 x64
  • test/v8/v8.test.ts - 22 failing on 🐧 3.20 x64-baseline
  • test/js/bun/http/serve.test.ts - segmentation fault on 🐧 3.20 aarch64
  • test/js/bun/http/serve.test.ts - segmentation fault on 🐧 3.20 x64
  • test/js/bun/http/serve.test.ts - segmentation fault on 🐧 3.20 x64-baseline
  • test/js/bun/http/serve.test.ts - 1 failing on 🍎 13 x64
  • test/js/bun/ffi/cc.test.ts - 1 failing on 🐧 3.20 aarch64
  • test/js/bun/ffi/cc.test.ts - 1 failing on 🐧 3.20 x64
  • test/js/bun/ffi/cc.test.ts - 1 failing on 🐧 3.20 x64-baseline
  • test/js/node/child_process/child_process.test.ts - 1 failing on 🐧 3.20 aarch64
  • test/js/node/child_process/child_process.test.ts - 1 failing on 🐧 3.20 x64
  • test/js/node/child_process/child_process.test.ts - 1 failing on 🐧 3.20 x64-baseline
  • test/cli/install/bun-link.test.ts - 4 failing on 🐧 3.20 aarch64
  • test/cli/install/bun-link.test.ts - 4 failing on 🐧 3.20 x64
  • test/cli/install/bun-link.test.ts - 4 failing on 🐧 3.20 x64-baseline
  • test/js/web/fetch/fetch.tls.test.ts - 1 failing on 🍎 14 aarch64
  • test/js/third_party/prisma/prisma.test.ts - segmentation fault on 🪟 2019 x64-baseline
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 22.04 x64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 20.04 x64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 3.20 aarch64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 3.20 x64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 3.20 x64-baseline
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 20.04 aarch64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 12 aarch64
  • test/js/third_party/prisma/prisma.test.ts - timeout on 🐧 22.04 aarch64
  • test/cli/run/require-cache.test.ts - 1 failing on 🪟 2019 x64