From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.4 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 648DB1F44D for ; Fri, 26 Apr 2024 07:04:46 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=80x24.org header.i=@80x24.org header.a=rsa-sha256 header.s=selector1 header.b=iTJeqDA5; dkim-atps=neutral Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s0FdO-00021j-GY; Fri, 26 Apr 2024 03:04:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s0FdM-00021V-W3 for dtas-all@nongnu.org; Fri, 26 Apr 2024 03:04:37 -0400 Received: from dcvr.yhbt.net ([173.255.242.215]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s0FdL-0001hc-IS for dtas-all@nongnu.org; Fri, 26 Apr 2024 03:04:36 -0400 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 7A4131F51A for ; Fri, 26 Apr 2024 07:04:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1714115056; bh=ndk7br1ohtRhG3QkVjibfzxsAeKAOpNlL3rFhoQIExM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=iTJeqDA5WbQEjzlb+Y8FVThkG/7Gk0tAPni2ZzZ1mwvIVeiL/lsPbFhQSZAdwxWhF BWX5ma6DqKXUrbI/wqd+Vaq8OsF7twSkofr+4DJX9esJoNN1tH2w9TgWK4j84qbwTa +Bi5Vx12Wij/Jx4JG0WGDAOsnSbyUEMKFpBaFkzc= From: Eric Wong To: dtas-all@nongnu.org Subject: [PATCH 2/3] use CPU rlimit to limit soxi||ffprobe run time Date: Fri, 26 Apr 2024 07:04:14 +0000 Message-ID: <20240426070416.497972-3-e@80x24.org> In-Reply-To: <20240426070416.497972-1-e@80x24.org> References: <20240426070416.497972-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=173.255.242.215; envelope-from=e@80x24.org; helo=dcvr.yhbt.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: duct tape audio suite List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dtas-all-bounces+e=80x24.org@nongnu.org Sender: dtas-all-bounces+e=80x24.org@nongnu.org soxi or ffprobe may infinite loop on bad files, so be sure to let these processes timeout properly. --- bin/dtas-readahead | 2 +- lib/dtas/source/av_ff_common.rb | 2 +- lib/dtas/source/sox.rb | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/dtas-readahead b/bin/dtas-readahead index f2ab514..c61d317 100755 --- a/bin/dtas-readahead +++ b/bin/dtas-readahead @@ -25,7 +25,7 @@ c = DTAS::UNIXClient.new @max_ra = 30 * 1024 * 1024 null = DTAS.null -@redir = { err: null, out: null, in: null }.freeze +@redir = { err: null, out: null, in: null, rlimit_cpu: [ 1, 2 ] }.freeze require 'pp' def seek_to_cur_pos(cur_pid, fp) diff --git a/lib/dtas/source/av_ff_common.rb b/lib/dtas/source/av_ff_common.rb index c600c48..7f197e0 100644 --- a/lib/dtas/source/av_ff_common.rb +++ b/lib/dtas/source/av_ff_common.rb @@ -92,7 +92,7 @@ def av_ff_ok? err = "".b begin - s = qx(@env, cmd, err_str: err, no_raise: true) + s = qx(@env, cmd, err_str: err, no_raise: true, rlimit_cpu: [ 1, 2 ]) rescue Errno::ENOENT # avprobe/ffprobe not installed return false end diff --git a/lib/dtas/source/sox.rb b/lib/dtas/source/sox.rb index c03477e..365c7b6 100644 --- a/lib/dtas/source/sox.rb +++ b/lib/dtas/source/sox.rb @@ -39,7 +39,8 @@ def initialize(mcache = nil) def mcache_lookup(infile) (@mcache ||= DTAS::Mcache.new).lookup(infile) do |input, dst| err = ''.b - out = qx(@env.dup, %W(soxi #{input}), err_str: err, no_raise: true) + out = qx(@env.dup, %W(soxi #{input}), err_str: err, no_raise: true, + rlimit_cpu: [ 1, 2 ]) return soxi_failed(infile, out) if Process::Status === out return soxi_failed(infile, err) if err =~ /soxi FAIL formats:/ out =~ /^Duration\s*:[^=]*= (\d+) samples /n