-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Uncatchable EINVAL when passing a 0-length array of buffers to FileHandle.writev #41910
Comments
Confirmed this reproduces on master, taking a look |
Opened a PR to fix at #41919 thanks for the detailed report |
There is a second issue here (other than the EINVAL) - the fact it's not catchable, I'll investigate |
This causes a segfault for example: // Writev with bad array-like
await assert.rejects(async () => {
const handle = await fs.open(getFileName(), 'w');
const badArray = new Proxy([], { get(target, prop) {
if(prop === 'length') return -1;
return Reflect.get(target, prop);
}});
const result = await handle.writev(badArray);
handle.close();
}, { code: 'EINVAL' });
So it looks like there are few other places to fix as well |
Yeah - we check IsArray which the v8 docs say:
|
Should this remain open to track the other problems discussed in #41919? |
Probably a good idea to open a new issue |
PR-URL: nodejs#41919 Fixes: nodejs#41910 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
PR-URL: nodejs#41932 Refs: nodejs#41910 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#41919 Fixes: nodejs#41910 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
PR-URL: nodejs#41932 Refs: nodejs#41910 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#41932 Refs: nodejs#41910 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Version
16.13.2
Platform
Linux [myhostname] 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
fs
What steps will reproduce the bug?
Invoke https://nodejs.org/api/fs.html#filehandlewritevbuffers-position with an empty array:
How often does it reproduce? Is there a required condition?
Unconditionally with the above reproduction. It also happens on macOS.
What is the expected behavior?
The resulting error should be caught and logged by the catch block.
Alternatively, this should not be an error at all. Writing no data with other FS functions does not result in errors.
What do you see instead?
The resulting error is uncatchable and kills the process.
Additional information
No response
The text was updated successfully, but these errors were encountered: