-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
os,vm: fix segfaults and CHECK failure
Fixes multiple possible segmentation faults in node_contextify.cc and an assertion failure in node_os.cc Fixes: #12369 Fixes: #12370 Backport-PR-URL: #13871 PR-URL: #12371 Reviewed-By: Anna Henningsen <anna@addaleax.net>
- Loading branch information
1 parent
5b74e63
commit 47e7020
Showing
3 changed files
with
157 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const execFile = require('child_process').execFile; | ||
|
||
const scripts = [ | ||
`os.userInfo({ | ||
get encoding() { | ||
throw new Error('xyz'); | ||
} | ||
})` | ||
]; | ||
|
||
['filename', 'cachedData', 'produceCachedData', 'lineOffset', 'columnOffset'] | ||
.forEach((prop) => { | ||
scripts.push(`vm.createScript('', { | ||
get ${prop} () { | ||
throw new Error('xyz'); | ||
} | ||
})`); | ||
}); | ||
|
||
['breakOnSigint', 'timeout', 'displayErrors'] | ||
.forEach((prop) => { | ||
scripts.push(`vm.createScript('').runInThisContext({ | ||
get ${prop} () { | ||
throw new Error('xyz'); | ||
} | ||
})`); | ||
}); | ||
|
||
scripts.forEach((script) => { | ||
const node = process.execPath; | ||
execFile(node, [ '-e', script ], common.mustCall((err, stdout, stderr) => { | ||
assert(stderr.includes('Error: xyz'), 'createScript crashes'); | ||
})); | ||
}); |