Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs: fix not found close creation context #53910

Closed
wants to merge 1 commit into from

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented Jul 17, 2024

Referencing a similar problem fixed by @santigimeno on #51286 (comment), this PR should fix the No creation context bug for close.

The easiest way to reproduce this is via:

const fs = require('fs')

let failed;
for (let i = 0; i < 1_000_000; i++) {
  failed = fs.readFile('./configure.py', (err, done) => {
    // do nothing
    console.log(err, done)
  })
}
console.log(failed)

Fixes #53902

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Jul 17, 2024
@nodejs-github-bot
Copy link
Collaborator

@RedYetiDev
Copy link
Member

FWIW I couldn't reproduce with that snippet (unless my computer crashing counts 🤣)!

@anonrig
Copy link
Member Author

anonrig commented Jul 17, 2024

@RedYetiDev I added a test which fails on macOS. If you have a hard limit on "number of open files" in environments like windows, it would throw an error, but the goal is to crash, not not to have errors.

@RedYetiDev
Copy link
Member

Thanks for adding the test :-)

Copy link
Member

@RedYetiDev RedYetiDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the rare chance that test-fs-close is moved for some reason.

test/parallel/test-fs-close-fast-api.js Outdated Show resolved Hide resolved
test/parallel/test-fs-close-fast-api.js Outdated Show resolved Hide resolved
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@richardlau
Copy link
Member

This looks related?

https://ci.nodejs.org/job/node-test-commit-arm-debug/13783/nodes=ubuntu2004_debug-arm64/consoleFull

15:42:00 not ok 1374 parallel/test-fs-close-fast-api
15:42:00   ---
15:42:00   duration_ms: 8968.09100
15:42:00   severity: crashed
15:42:00   exitcode: -6
15:42:00   stack: |-
15:42:00     undefined
15:42:00     FATAL ERROR: v8::HandleScope::CreateHandle() Cannot create a handle without a HandleScope
15:42:00     ----- Native stack trace -----
15:42:00     
15:42:00      1: 0xaaaab4399ce4 node::DumpNativeBacktrace(_IO_FILE*) [out/Debug/node]
15:42:00      2: 0xaaaab44e5018 node::OnFatalError(char const*, char const*) [out/Debug/node]
15:42:00      3: 0xaaaab4950dc0 v8::Utils::ReportApiFailure(char const*, char const*) [out/Debug/node]
15:42:00      4: 0xaaaab4cfd02c v8::internal::HandleScope::Extend(v8::internal::Isolate*) [out/Debug/node]
15:42:00      5: 0xaaaab49412d0 v8::internal::HandleScope::CreateHandle(v8::internal::Isolate*, unsigned long) [out/Debug/node]
15:42:00      6: 0xaaaab4990120 v8::Object::GetCreationContext() [out/Debug/node]
15:42:00      7: 0xaaaab49901b0 v8::Object::GetCreationContextChecked() [out/Debug/node]
15:42:00      8: 0xaaaab44f3a9c  [out/Debug/node]
15:42:00      9: 0xffff98069f10 
15:42:00   ...

@anonrig
Copy link
Member Author

anonrig commented Jul 18, 2024

@santigimeno @joyeecheung can you take a look?

@RedYetiDev
Copy link
Member

For reference,

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error   <https://github.com/npm/cli/issues>

still occurs on this PR (at least from my testing).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Node 22.5.0 started to crash and hangs on different cases
4 participants