Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.3k
fs: guard against undefined behavior#34746
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
Calling close on a file description which is currently in use is undefined behavior due to implementation details in libuv. Add a guard against this when using FileHandle.
03ee3d5 to bc670bdCompare6169687 to 107f508Compare4a3099a to 711653aComparenodejs-github-bot commented Aug 12, 2020
ronag commented Aug 12, 2020
@nodejs/fs |
jasnell commented Aug 12, 2020 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@addaleax ... This brought an edge case to mind that I'm not sure how we're handling... What should happen in the following case 'use strict';constfs=require('fs');const{ Worker, workerData, isMainThread }=require('worker_threads');if(isMainThread){asyncfunctionfoo(){constfh=awaitfs.promises.open(__filename);constbuffer=Buffer.alloc(1000);// Not awaiting...constp=fh.read(buffer,0,1000);// Transferring the FileHandle while there's potentially// an outstanding async operation on it.constw=newWorker(__filename,{workerData: fh,transferList: [fh]});// Then awaiting...awaitp;returnbuffer.toString();}foo().then(console.log);}else{workerData.close();}First immediate thought is that we should throw if attempting to transfer a |
addaleax commented Aug 13, 2020
Yeah, I agree – that sounds like the best approach to me 👍 |
nodejs-github-bot commented Aug 13, 2020
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jasnell commented Aug 13, 2020
It would likely be good to add a comment to the fs.md documentation for |
Co-authored-by: James M Snell <[email protected]>
ronag commented Aug 13, 2020
Fixed |
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: James M Snell <[email protected]>
nodejs-github-bot commented Aug 13, 2020
nodejs-github-bot commented Aug 13, 2020 • edited by ronag
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by ronag
Uh oh!
There was an error while loading. Please reload this page.
This can currently be triggered when posting a closing FileHandle. Refs: nodejs#34746 (comment)
ronag commented Aug 14, 2020
Landed in a0f87aa |
Calling close on a file description which is currently in use is undefined behavior due to implementation details in libuv. Add a guard against this when using FileHandle. PR-URL: #34746 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]>
This can currently be triggered when posting a closing FileHandle. Refs: #34746 (comment) PR-URL: #34766 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]>
This can currently be triggered when posting a closing FileHandle. Refs: nodejs#34746 (comment) PR-URL: nodejs#34766 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]>
Calling close on a file description which is currently in use is undefined behavior due to implementation details in libuv. Add a guard against this when using FileHandle. PR-URL: #34746 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]>
This can currently be triggered when posting a closing FileHandle. Refs: #34746 (comment) PR-URL: #34766 Backport-PR-URL: #34814 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]>
Calling close on a file description which is currently in use is undefined behavior due to implementation details in libuv. Add a guard against this when using FileHandle. PR-URL: #34746 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]>
This can currently be triggered when posting a closing FileHandle. Refs: #34746 (comment) PR-URL: #34766 Backport-PR-URL: #34814 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]>
This can currently be triggered when posting a closing FileHandle. Refs: #34746 (comment) PR-URL: #34766 Backport-PR-URL: #34814 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]>
This can currently be triggered when posting a closing FileHandle. Refs: #34746 (comment) PR-URL: #34766 Backport-PR-URL: #34814 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: James M Snell <[email protected]>
Calling close on a file description which is currently in use is
undefined behavior due to implementation details in libuv. Add
a guard against this when using FileHandle.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes