mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
With V8_ENABLE_SANDBOX every ArrayBuffer backing store has to be allocated inside the sandbox, so memory that Node.js or a library allocated itself cannot be wrapped and has to be copied in. Several places already special-cased this, each with its own #ifdef, but a build with the sandbox enabled still failed to compile (`kMaxSafeBufferSizeForSandbox`), aborted in `crypto.randomUUID()` (`SecureBuffer` was UNREACHABLE) and threw from every caller of the malloc-owning `Buffer::New()` (v8.serialize, string transcoding, IPC, the public `Buffer::New(isolate, data, length)`), and trace_events, SEA assets and FFI still wrapped outside memory unconditionally. Add `AdoptIntoBackingStore()`, which wraps the memory as before in regular builds and copies it into an isolate-allocated backing store, running the deleter right away, when the sandbox is enabled, and use it at all of those sites so the #ifdef lives in one place. The trace category flag cannot be copied since JS polls it, so under the sandbox `getCategoryEnabledBuffer()` returns nothing and lib falls back to `isTraceCategoryEnabled()`; FFI zero-copy views throw ERR_OPERATION_FAILED there for the same reason. Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com> PR-URL: https://github.com/nodejs/node/pull/62237 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
121 lines
1.9 KiB
JavaScript
121 lines
1.9 KiB
JavaScript
import { createRequire } from 'module';
|
|
|
|
const require = createRequire(import.meta.url);
|
|
const common = require('./index.js');
|
|
|
|
const {
|
|
allowGlobals,
|
|
buildType,
|
|
canCreateSymLink,
|
|
childShouldThrowAndAbort,
|
|
enoughTestMem,
|
|
escapePOSIXShell,
|
|
expectsError,
|
|
expectWarning,
|
|
getArrayBufferViews,
|
|
getBufferSources,
|
|
getTTYfd,
|
|
hasCrypto,
|
|
hasDtls,
|
|
hasQuic,
|
|
hasInspector,
|
|
hasSQLite,
|
|
hasFFI,
|
|
hasLocalStorage,
|
|
hasIntl,
|
|
hasTemporal,
|
|
hasV8Sandbox,
|
|
hasIPv6,
|
|
isAIX,
|
|
isAlive,
|
|
isFreeBSD,
|
|
isIBMi,
|
|
isInsideDirWithUnusualChars,
|
|
isLinux,
|
|
isOpenBSD,
|
|
isMacOS,
|
|
isRiscv64,
|
|
isSunOS,
|
|
isWindows,
|
|
localIPv6Hosts,
|
|
mustCall,
|
|
mustCallAtLeast,
|
|
mustNotCall,
|
|
mustNotMutateObjectDeep,
|
|
mustSucceed,
|
|
nodeProcessAborted,
|
|
parseTestMetadata,
|
|
PIPE,
|
|
platformTimeout,
|
|
printSkipMessage,
|
|
runWithInvalidFD,
|
|
skip,
|
|
skipIf32Bits,
|
|
skipIfEslintMissing,
|
|
skipIfInspectorDisabled,
|
|
skipIfSQLiteMissing,
|
|
skipIfPerfettoEnabled,
|
|
spawnPromisified,
|
|
sleepSync,
|
|
} = common;
|
|
|
|
const getPort = () => common.PORT;
|
|
|
|
export {
|
|
allowGlobals,
|
|
buildType,
|
|
canCreateSymLink,
|
|
childShouldThrowAndAbort,
|
|
createRequire,
|
|
enoughTestMem,
|
|
escapePOSIXShell,
|
|
expectsError,
|
|
expectWarning,
|
|
getArrayBufferViews,
|
|
getBufferSources,
|
|
getPort,
|
|
getTTYfd,
|
|
hasCrypto,
|
|
hasDtls,
|
|
hasQuic,
|
|
hasInspector,
|
|
hasSQLite,
|
|
hasFFI,
|
|
hasLocalStorage,
|
|
hasIntl,
|
|
hasTemporal,
|
|
hasV8Sandbox,
|
|
hasIPv6,
|
|
isAIX,
|
|
isAlive,
|
|
isFreeBSD,
|
|
isIBMi,
|
|
isInsideDirWithUnusualChars,
|
|
isLinux,
|
|
isOpenBSD,
|
|
isMacOS,
|
|
isRiscv64,
|
|
isSunOS,
|
|
isWindows,
|
|
localIPv6Hosts,
|
|
mustCall,
|
|
mustCallAtLeast,
|
|
mustNotCall,
|
|
mustNotMutateObjectDeep,
|
|
mustSucceed,
|
|
nodeProcessAborted,
|
|
parseTestMetadata,
|
|
PIPE,
|
|
platformTimeout,
|
|
printSkipMessage,
|
|
runWithInvalidFD,
|
|
skip,
|
|
skipIf32Bits,
|
|
skipIfEslintMissing,
|
|
skipIfInspectorDisabled,
|
|
skipIfSQLiteMissing,
|
|
skipIfPerfettoEnabled,
|
|
spawnPromisified,
|
|
sleepSync,
|
|
};
|