From b850fbdca30284daa44527080cab596d118a3c69 Mon Sep 17 00:00:00 2001 From: Marek Materzok Date: Fri, 19 Jan 2024 13:52:46 +0100 Subject: [PATCH] Add `timeout` for better protection --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index eea71ae..5e548f6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1204,7 +1204,7 @@ export async function verilator_lint(filenames: string[], dirname?: string, opti try { const output: LintMessage[] = []; const verilator_result: {stdout: string, stderr: string} = await promisify(child_process.exec)( - 'verilator -lint-only -Wall -Wno-DECLFILENAME -Wno-UNOPT -Wno-UNOPTFLAT ' + filenames.map(shell_escape).join(' '), + 'timeout -k10s 40s verilator -lint-only -Wall -Wno-DECLFILENAME -Wno-UNOPT -Wno-UNOPTFLAT ' + filenames.map(shell_escape).join(' '), {maxBuffer: 1000000, cwd: dirname || null, timeout: options.timeout || 60000}) .catch(exc => exc); for (const line of verilator_result.stderr.split('\n')) { @@ -1246,7 +1246,7 @@ export async function process(filenames: string[], dirname?: string, options: Op const tmpjson = await tmp.tmpName({ postfix: '.json' }); let obj = undefined; const yosys_result: {stdout: string, stderr: string, killed?: boolean, code?: number} = await promisify(child_process.exec)( - 'yosys -p "' + shell_escape_contents(filenames.map(process_filename).join('; ')) + + 'timeout -k10s 40s yosys -p "' + shell_escape_contents(filenames.map(process_filename).join('; ')) + '; hierarchy -auto-top; proc' + optimize_simp + fsmpass + '; memory -nomap; wreduce -memx' + optimize + '" -o "' + tmpjson + '"', {maxBuffer: 1000000, cwd: dirname || null, timeout: options.timeout || 60000})