From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 3D1741FF179 for ; Wed, 7 Jan 2026 14:09:31 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 733C7D1A6; Wed, 7 Jan 2026 14:10:46 +0100 (CET) Message-ID: Date: Wed, 7 Jan 2026 14:10:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Proxmox Backup Server development discussion , Robert Obkircher References: <20251230124154.115442-1-r.obkircher@proxmox.com> <20251230124154.115442-2-r.obkircher@proxmox.com> Content-Language: en-US, de-DE From: Christian Ebner In-Reply-To: <20251230124154.115442-2-r.obkircher@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1767791376025 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.048 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pbs-devel] [PATCH v2 proxmox-backup 1/2] datastore: check for null pointer when allocating DynamicIndexHeader X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Please provide a short commit message on why this is done. As far as I see this now panics in handle_alloc_error() if either memory is exhausted or the layout does not fit the allocator constraints, while previously this failed on Box::from_raw() for the null pointer? So maybe better to propagate the allocation error to the call site of zeroed() in DynamicIndexWriter::create() and return it there as well? On 12/30/25 1:42 PM, Robert Obkircher wrote: > Signed-off-by: Robert Obkircher > --- > pbs-datastore/src/dynamic_index.rs | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/pbs-datastore/src/dynamic_index.rs b/pbs-datastore/src/dynamic_index.rs > index ad49cdf3..12df78b1 100644 > --- a/pbs-datastore/src/dynamic_index.rs > +++ b/pbs-datastore/src/dynamic_index.rs > @@ -41,13 +41,20 @@ proxmox_lang::static_assert_size!(DynamicIndexHeader, 4096); > impl DynamicIndexHeader { > /// Convenience method to allocate a zero-initialized header struct. > pub fn zeroed() -> Box { > + let layout = std::alloc::Layout::new::(); > unsafe { > - Box::from_raw(std::alloc::alloc_zeroed(std::alloc::Layout::new::()) as *mut Self) > + let ptr = std::alloc::alloc_zeroed(layout) as *mut Self; > + if ptr.is_null() { > + std::alloc::handle_alloc_error(layout); > + } > + Box::from_raw(ptr) > } > } > > pub fn as_bytes(&self) -> &[u8] { > unsafe { > + // There can't be any uninitialized padding, because the fields > + // take up all of the statically asserted total size. > std::slice::from_raw_parts( > self as *const Self as *const u8, > std::mem::size_of::(), _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel