From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 6DE77484FA for ; Wed, 6 Dec 2023 12:31:03 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A38A668CF77; Wed, 6 Dec 2023 14:31:01 +0200 (EET) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8DF2E68CEB1 for ; Wed, 6 Dec 2023 14:30:55 +0200 (EET) Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1d05199f34dso34081395ad.3 for ; Wed, 06 Dec 2023 04:30:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701865853; x=1702470653; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=anM9lOGVef3i2sI0hT7b+OTiasN/xcREI8bGS0K77oM=; b=BsQeQjdWJcSnj6pglDHjypE+vc4iEt+GvULL6qMQEN31y8JB3/GeOv7PyXeYNwZLTq qFhgUuvMQWDgOUu1uYPHR/Zu3hAoHzBZ3Kepoc5CCTB5qkOeoT+4PAeEo+llE6sE4IVf rtRlRIjBh/wfZn6SyiJ9r2hPg2VjcB9gunvb0aLj2Am9ujNEKuSC6uNQHznnKpF7Ih4r Blm4JbHb97NfcJts/U+UqzaqgfY1G2dNm1QoS1Valx0hDcUCXNg4NrYLY8d58lS6fkBr UhdC2GeFXsflEmTOtk6RGpTd40GBVFGrumq08eSiOAQSPedQhDk4ZGQGuCfp4Dr0TtzY YG9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701865853; x=1702470653; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=anM9lOGVef3i2sI0hT7b+OTiasN/xcREI8bGS0K77oM=; b=m/8ilnzjAqZfr8hUdooHsRbUCxkXE9rVrt4i/T9x1q20G2xux8VGtfBBnM6D3vi567 B5ZT9rYL+lXTJ+vnv0w2qnlYStXSkAw3KubZ2NIuS6+z9coMOt6SBM36d6BUN5Hz1JyE SoFn7FNHHTcpS0UOdHfvoyf+ObB+C14Xe9JKJIALbv1mQm9Yvxf/xhfMIpclM3rpjOaK +qJknhjHmzB6fTkB0R3nK8BURhJgVUfG6UV7LRpprY8b3V32q8sXI6dB3b59NPs2kpdo dVK9O+qHJ5+U0BXWrfWFxtPUEEv7LmRAbZHHVOKCxSD7uwjpHnb2dUu/F++MLd5vThtH YQ/A== X-Gm-Message-State: AOJu0YzVADg8j/HP4QMUHZgheqLRcCNlV+fzvaBsxfyL4GPMTEJQrStD Ey9pWBibelJWXMR8ewbfUrv/T4Xkev8= X-Google-Smtp-Source: AGHT+IGOVmf95YkxaGiIEQZb0BsnaOk4bBCh6a5O0zwK6ppEvTmpKHTYlaQ3lyCBm8szaVgWcCv9Cg== X-Received: by 2002:a17:902:eb46:b0:1d0:6ffd:6e80 with SMTP id i6-20020a170902eb4600b001d06ffd6e80mr580481pli.120.1701865852745; Wed, 06 Dec 2023 04:30:52 -0800 (PST) Received: from [192.168.0.16] (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id c13-20020a170902d48d00b001d052d1aaf2sm3202152plg.101.2023.12.06.04.30.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Dec 2023 04:30:52 -0800 (PST) Message-ID: <0931e72c-9cb3-47b3-8cd8-fb07c911a453@gmail.com> Date: Wed, 6 Dec 2023 09:31:31 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: <20231203201027.2255-1-timo@rothenpieler.org> Content-Language: en-US From: James Almer Autocrypt: addr=jamrial@gmail.com; keydata= xsBNBFjZtqABCADLW+vdEoZaJZDsIO6geYFTOcn1unsEHefj9zn+3oTHlDFFzO47mzHsSfbK 9JE2xpOJEVnC8FAF5Sayi/pVwV+mtQUV3n5dgVeVBYF9GUQwOGFCpK8X54RRqhkgknbunOEE 0CtgAJgmpFmmmHgq02GvEspx1h/rh4apqwQR6QX4Favb+x9+i9ytVpwVcBX94vo2toyP7h/K BWfadQmb8ltgE1kshfg+SQs/H5bTV5Z1DuEASf02ZL/1qYB/sdTgWPLv9XMUHHsRFmMY8TMx wJSkP+Af3AiYQPJYz1B1D4tt98T/NoiVdin10zATakPjV8hXaobuRmxgakkUASXudydDABEB AAHNH0phbWVzIEFsbWVyIDxqYW1yaWFsQGdtYWlsLmNvbT7CwJIEEwEIADwCGwMGCwkIBwMC BhUIAgkKCwQWAgMBAh4BAheAFiEEd1EujP2UoWlX5pp6FGMBrXN2WeAFAmJoLUUCGQEACgkQ FGMBrXN2WeAFVQf9GtGhniRs1PzNUOgJktCnv6j4BbLieaIPYPEFXKDHOgjqQE2zVMYXnoXl Jam928ii902a8OY06r9ywn/R8ApD1/3NY/v64O71CY9scz5XyH2au8wIZ6HwFy3/f7sqjdGD uctY8Qs7rjT7NkoC5lmgMu2v2k03dGtM9AAf5AK5gU+H0EUw7vmKKiXzUqt5kvBuf4CEwXvH AQT1SMJ52rIlDWB7FQFyZeUbOAK2IgY/KNedfK6nsgd/eQVnlofPd2XoddE7kP6iys7jJefw DD3g3rZyDTq7in5dyk5glaNpWZpbHGBs+9SCYLnfQ8XvWqPFOD+gj0plamKANgOvavKTxM7A TQRY2bagAQgA69YtILj8kYxmqPr/M8+MXT7wVoOWVW9lvSmPquCELaDy/NIS7D06VC5EuE/6 JlJXZMTn37NLlyWhzwOgXuXw5w2tyoQQBuvqGiXJijuXwXH7HKdzrc6rpYtAqt5w05hzNrFS KrS0izG64VpWrfproy3BsL+8TBm9brLhhNPynVRqVukbbGzlATTzNQGZ14TTi2/dL6DkMQnM qn4jX9UEe4GdGQBP50bUJSSmeiIkyNLWA+znuN2PZEz930ZwNrF9GtDVw7mzcmpCZ7spldE2 tutbpy9D1bIqxyqBrYDSezyzL2adR1qgHyOTMCHg2AYNkrIQHrSyJxKTpZ1/hqOp8wARAQAB wsBfBBgBAgAJBQJY2bagAhsMAAoJEBRjAa1zdlnghekH/0Yb0iYJ74oID2f/Fj+AJKS2ekQF P2xOr8lpGzgp/+yWUvPtqbX0A33anBJdYwxaAC0NataX3tfZ+oJkzXqfmqhIHMPYHdZesJA2 Bk9hU/33mDl5s5U66/z0uelWzwKVHoQ2O6or4+qF3HJFSJLCe9uvWJ3zXf9F342Ftj73sfx+ 3xkw/IXsN1RqbYqDlzpoEQ99SIEfY/8Jjwnd3sIPfqkuyeaYfe6GJDqKawdCEP1oRRlbXEAp TJgYz8r3nPhGv9cdHNDCk44ISbsqVuxIEnLqi4fTPZaGupiQhT+srl268TTAp2TQW7+6Ce/b NPQorMquzS/LZoyALpmsYi/miMc= In-Reply-To: <20231203201027.2255-1-timo@rothenpieler.org> Subject: Re: [FFmpeg-devel] [PATCH] avutil/mem: always align by at least 32 bytes X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 12/3/2023 5:10 PM, Timo Rothenpieler wrote: > FFmpeg has instances of DECLARE_ALIGNED(32, ...) in a lot of structs, > which then end up heap-allocated. > By declaring any variable in a struct, or tree of structs, to be 32 byte > aligned, it allows the compiler to safely assume the entire struct > itself is also 32 byte aligned. > > This might make the compiler emit code which straight up crashes or > misbehaves in other ways, and at least in one instances is now > documented to actually do (see ticket 10549 on trac). > The issue there is that an unrelated variable in SingleChannelElement is > declared to have an alignment of 32 bytes. So if the compiler does a copy > in decode_cpe() with avx instructions, but ffmpeg is built with > --disable-avx, this results in a crash, since the memory is only 16 byte > aligned. Wont we run into similar issues with avx512 eventually? > Mind you, even if the compiler does not emit avx instructions, the code > is still invalid and could misbehave. It just happens not to. Declaring > any variable in a struct with a 32 byte alignment promises 32 byte > alignment of the whole struct to the compiler. > > Instead of now going through all instances of variables in structs > being declared as 32 byte aligned, this patch bumps the minimum alignment > to 32 bytes. > --- > libavutil/mem.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavutil/mem.c b/libavutil/mem.c > index 36b8940a0c..26a9b9753b 100644 > --- a/libavutil/mem.c > +++ b/libavutil/mem.c > @@ -62,7 +62,7 @@ void free(void *ptr); > > #endif /* MALLOC_PREFIX */ > > -#define ALIGN (HAVE_AVX512 ? 64 : (HAVE_AVX ? 32 : 16)) > +#define ALIGN (HAVE_AVX512 ? 64 : 32) > > /* NOTE: if you want to override these functions with your own > * implementations (not recommended) you have to link libav* as _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".