From 542744bb6e367523d5c484a9e306e945c9ca3042 Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Sat, 9 Apr 2022 11:39:03 +0530 Subject: [PATCH] src,inspector: fix empty MaybeLocal crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return early when the Inspector StringView to V8 String conversion fails and returns an empty MaybeLocal instead of running the invalid ToLocalChecked() assertion. Fixes: https://github.com/nodejs/node/issues/42407 Signed-off-by: Darshan Sen PR-URL: https://github.com/nodejs/node/pull/42409 Backport--PR-URL: https://github.com/nodejs/node/pull/42967 Reviewed-By: Richard Lau Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Anna Henningsen Reviewed-By: Tobias Nießen Reviewed-By: Juan José Arboleda Reviewed-By: James M Snell --- .../test-repl-empty-maybelocal-crash.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/pummel/test-repl-empty-maybelocal-crash.js diff --git a/test/pummel/test-repl-empty-maybelocal-crash.js b/test/pummel/test-repl-empty-maybelocal-crash.js new file mode 100644 index 00000000000000..84686e308c6157 --- /dev/null +++ b/test/pummel/test-repl-empty-maybelocal-crash.js @@ -0,0 +1,20 @@ +'use strict'; +const common = require('../common'); + +if (process.config.variables.arm_version === '7') { + common.skip('Too slow for armv7 bots'); +} + +// The process should not crash when the REPL receives the string, 'ss'. +// Test for https://github.com/nodejs/node/issues/42407. + +const repl = require('repl'); + +const r = repl.start(); + +r.write('var buf = Buffer.from({length:200e6},(_,i) => i%256);\n'); +r.write('var ss = buf.toString("binary");\n'); +r.write('ss'); +r.write('.'); + +r.close();