From patchwork Fri Oct 16 08:57:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Tjernlund X-Patchwork-Id: 23002 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 0FD464493E2 for ; Fri, 16 Oct 2020 11:57:36 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DEF0868BBEA; Fri, 16 Oct 2020 11:57:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-eopbgr760053.outbound.protection.outlook.com [40.107.76.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 543C368B877 for ; Fri, 16 Oct 2020 11:57:29 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KPlW1Ifg0/1iDV3BFrHJJ0IOrkFsmto9xq/OseLan0JTdOnni29T417+XHnKLF2tGml/oDBLnYeREOLbu249mrLGS7ZA2NoCiaAHw/RnA2lJArlpAUleXRy98+vG6pTenkZ2v5XL7ctmcGaB9bjO60IeWdTqVs+BN/WBJ3lKsXqCmcl3KKNAb52MI9Z1/4jhOPeai7K7DKs/mtGKuvsxjhM/dp7KcvsfsaAnREZCS3+nv7LHbKjnpDtY3wGWqz/QfdjQO59LNf/riYhR0xnufycM4fKjp2U9W8SDe1fStKweQDYLuAooeQrVHkfdc9GrYh0ViheNovWWv+3pYk71PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZQbXpMq8xUWKi5e4d19cbvbg+h9ehebZfJUpRyYzzBY=; b=mw9EKeaGiVJLeJ07fis4GiMUS8rQgbGwak+GSRvYt217PPs5KrEvYed/BdUU9LJqKNRTmtcTYK+Cb3P9tGfSo5BBtMNkfX48ofA4zcVNJBPFkSFzzfzlyG24OnGYKjgoUDXvZbQFLojnL+ZGsI8VxOXwlOAnUWvgccJHR3Wohx7UnGmdJOrseVIel/x04/2KsU/SFjcgx09lqf0PB4vpQ2PGUjvWW81ok+bcXPKNE1oT5fflnlXsuXUj/TKqZOfYHS0a+YZWO1PB/sKWycpm8uVBniWsRLbVuYjxbF1Hs1VW6MDRjrBe3Vba/w37NrZycBoZ5w5EmJQJiiRjj+2PIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 8.4.225.191) smtp.rcpttodomain=ffmpeg.org smtp.mailfrom=infinera.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=infinera.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=infinera.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZQbXpMq8xUWKi5e4d19cbvbg+h9ehebZfJUpRyYzzBY=; b=E7ofwtVkcQM5StK6G7WZPH3CbVbPx2F/QP8DEV3rKtyeYrnmy7EpIT6XXgvN6SKvfkeceb/QgiUjzw0XHgsHJpv1FhIEGRSn0hmo5rR3/GQ4MXxxqbDPUlyuzvmeHpOF1HObPxoKuTzzVsoPkeMIy91mqJX9Kn+9NrLnXY65jkk= Received: from MW2PR2101CA0013.namprd21.prod.outlook.com (2603:10b6:302:1::26) by DM6PR10MB2809.namprd10.prod.outlook.com (2603:10b6:5:63::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.23; Fri, 16 Oct 2020 08:57:26 +0000 Received: from CO1NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:302:1:cafe::85) by MW2PR2101CA0013.outlook.office365.com (2603:10b6:302:1::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.4 via Frontend Transport; Fri, 16 Oct 2020 08:57:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 8.4.225.191) smtp.mailfrom=infinera.com; ffmpeg.org; dkim=none (message not signed) header.d=none;ffmpeg.org; dmarc=pass action=none header.from=infinera.com; Received-SPF: Pass (protection.outlook.com: domain of infinera.com designates 8.4.225.191 as permitted sender) receiver=protection.outlook.com; client-ip=8.4.225.191; helo=owa.infinera.com; Received: from owa.infinera.com (8.4.225.191) by CO1NAM11FT058.mail.protection.outlook.com (10.13.174.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3477.23 via Frontend Transport; Fri, 16 Oct 2020 08:57:25 +0000 Received: from sv-ex16-prd.infinera.com (10.100.96.229) by sv-ex16-prd.infinera.com (10.100.96.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1847.3; Fri, 16 Oct 2020 01:57:24 -0700 Received: from sv-smtp-prod2.infinera.com (10.100.98.82) by sv-ex16-prd.infinera.com (10.100.96.229) with Microsoft SMTP Server id 15.1.1847.3 via Frontend Transport; Fri, 16 Oct 2020 01:57:24 -0700 Received: from se-metroit-prd1.infinera.com ([10.210.32.58]) by sv-smtp-prod2.infinera.com with Microsoft SMTPSVC(7.5.7601.17514); Fri, 16 Oct 2020 01:57:24 -0700 Received: from gentoo-jocke.infinera.com (gentoo-jocke.infinera.com [10.210.71.2]) by se-metroit-prd1.infinera.com (Postfix) with ESMTP id F40EF2C03201 for ; Fri, 16 Oct 2020 10:57:23 +0200 (CEST) Received: by gentoo-jocke.infinera.com (Postfix, from userid 1001) id EE5C9C6A8; Fri, 16 Oct 2020 10:57:23 +0200 (CEST) From: Joakim Tjernlund To: FFmpeg development discussions and patches Date: Fri, 16 Oct 2020 10:57:22 +0200 Message-ID: <20201016085722.21866-1-joakim.tjernlund@infinera.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-OriginalArrivalTime: 16 Oct 2020 08:57:24.0934 (UTC) FILETIME=[5DE13660:01D6A39A] X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0640f6e1-bdb4-45fd-9236-08d871b180a1 X-MS-TrafficTypeDiagnostic: DM6PR10MB2809: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1417; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1qB2x7mvoNqFzJRLKgvXq2/jXQSp2qO/bvEtI7nXQXdBLIwyNmbc6MmGh5Hf8zqkswBBenQwfe3JGx5R8QjTWURikN24a0Uy1672uhYi2TKiSXHCMQaecGpGQTQhJFln+hD5NGyBoLfPFxpbYgDpD3zQfmC006AMXhW4pJ/5cYXhLyFP1EEI39v3BEDHmY6c+fcJpsZr/zhYCVIG02EVX8M+jrFKIiPz9amk24yhVRJzbTm5hVrjQmc4LZOx7hSSwmNAcl1LZyfymbtDc/C6RM9w+e144/EAMX/xp5JNIljtO5fFM25TKv8KvZiOjDrmNHh1dqFL4NatVkwFiXBcOsEfQ6uU9NFZylwmf9a7yyF0OP28xAsmA3rtQkjwdTIDSQat5BNeXEzFY4ATJJzoqmhyIJNZnE3yW1L6XJYZTxzgOGLFKj0gWFJXh3VBZFjTeFcH8GwqFWQAINCzX02LdhRsemzZri+6fH6ddYhQyWo= X-Forefront-Antispam-Report: CIP:8.4.225.191; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:owa.infinera.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(39860400002)(396003)(136003)(376002)(346002)(46966005)(36906005)(8676002)(8936002)(478600001)(107886003)(82310400003)(4326008)(1076003)(86362001)(6266002)(426003)(356005)(70586007)(47076004)(2616005)(82740400003)(966005)(186003)(70206006)(42186006)(26005)(316002)(5660300002)(81166007)(44832011)(83380400001)(6916009)(336012)(36756003)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: infinera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 08:57:25.3577 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0640f6e1-bdb4-45fd-9236-08d871b180a1 X-MS-Exchange-CrossTenant-Id: 285643de-5f5b-4b03-a153-0ae2dc8aaf77 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=285643de-5f5b-4b03-a153-0ae2dc8aaf77; Ip=[8.4.225.191]; Helo=[owa.infinera.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB2809 Subject: [FFmpeg-devel] [PATCH v4] Unbreak av_malloc_max(0) API/ABI X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Joakim Tjernlund Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From https://bugs.chromium.org/p/chromium/issues/detail?id=1095962 ---------------------------- This seems to be caused by the custom handling of "av_max_alloc(0)" in Chromium's ffmpeg fork to mean unlimited (added in [1]). Upstream ffmpeg doesn't treat 0 as a special value; versions before 4.3 seemingly worked because 32 was subtracted from max_alloc_size (set to 0 by Chromium) resulting in an integer underflow, making the effective limit be SIZE_MAX - 31. Now that the above underflow doesn't happen, the tab just crashes. The upstream change for no longer subtracting 32 from max_alloc_size was included in ffmpeg 4.3. [2] [1] https://chromium-review.googlesource.com/c/chromium/third_party/ffmpeg/+/73563 [2] https://github.com/FFmpeg/FFmpeg/commit/731c77589841 --------------------------- Restore av_malloc_max(0) to MAX_INT fixing MS Teams, Discord older chromium etc. Signed-off-by: Joakim Tjernlund --- v2: Cover the full API range 0-31 v3: Closer compat with < 4.3 ffmpeg v4: Adjust size accoriding to Andreas Rheinhardt comments libavutil/mem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavutil/mem.c b/libavutil/mem.c index cfb6d8a..44870a9 100644 --- a/libavutil/mem.c +++ b/libavutil/mem.c @@ -71,6 +71,8 @@ void free(void *ptr); static size_t max_alloc_size= INT_MAX; void av_max_alloc(size_t max){ + if (max < 32) + max = SIZE_MAX - 32 + max; /* be compatible to older(< 4.3) versions */ max_alloc_size = max; }