From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 4DA021F9FC for ; Mon, 1 Nov 2021 19:06:09 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/2] idx_stack: avoid conditional hash assignment weirdness Date: Mon, 1 Nov 2021 19:06:08 +0000 Message-Id: <20211101190609.32278-2-e@80x24.org> In-Reply-To: <20211101190609.32278-1-e@80x24.org> References: <20211101190609.32278-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: I've been seeing the following error on occasion during "make check-run": $PWD/t/data-gen/reindex-time-range.v1-master index failed: Modification of a read-only value attempted at $DIR/lib/PublicInbox/SearchIdx.pm line 899, <$r> line 1. Perhaps this fixes it. In any case, a construct of: $h->{k} //= do { $h->{x} = ...; $val }; seems wrong and may cause Perl to error out depending on how hashes are randomized. --- lib/PublicInbox/IdxStack.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/IdxStack.pm b/lib/PublicInbox/IdxStack.pm index d5123006..54d480bd 100644 --- a/lib/PublicInbox/IdxStack.pm +++ b/lib/PublicInbox/IdxStack.pm @@ -20,12 +20,12 @@ sub new { sub push_rec { my ($self, $file_char, $at, $ct, $blob_oid, $cmt_oid) = @_; my $rec = pack(PACK_FMT, $file_char, $at, $ct, $blob_oid, $cmt_oid); - $self->{unpack_fmt} //= do { + $self->{unpack_fmt} // do { my $len = length($cmt_oid); my $fmt = PACK_FMT; $fmt =~ s/H\*/H$len/g; $self->{rec_size} = length($rec); - $fmt; + $self->{unpack_fmt} = $fmt; }; print { $self->{wr} } $rec or die "print: $!"; $self->{tot_size} += length($rec);