Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1minkj-0005Ri-Kj for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Nov 2021 01:10:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1minkA-00026H-Ev for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Nov 2021 01:10:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mink9-00025v-Rr for pgsql-hackers@lists.postgresql.org; Fri, 05 Nov 2021 01:10:10 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mink5-0002VN-D5 for pgsql-hackers@postgresql.org; Fri, 05 Nov 2021 01:10:09 +0000 Received: by mail-ed1-x534.google.com with SMTP id ee33so27761334edb.8 for ; Thu, 04 Nov 2021 18:10:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=/JaVV+LiaWYdf1GDS2pGgy2XHzsraH5ZHWLEhkr/8PM=; b=mCjbqE0iopGkAK6hGJ+K3Q87lwwF+WwBIzlLHf51WX2nosCZQaKDt7xK3zgZcVNwut kAf9/l9pULsns12dR7wnQaS7aMX9kl44VstvY0isrhtHH6pZK6Ju2txcBohj8mJ6Pud+ PjwfDlzbWp4xMzy+36WRNho0YFq0w2fxy9ChwFsniXr94NMLH/FUUyrTwiJxdwJ8/Wro aebWTMjUM9kyUhc96ip91eduHOofY3oxmZyPBcX5oMGAUPM4Q36t0J4tl31/qMBURt9e NkqYKHmj46vF0czYchUoGaqx/lsUK+HUuqMdpa8ROvHCaihEiojadZqWHu4sPE2jvdAd bWLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=/JaVV+LiaWYdf1GDS2pGgy2XHzsraH5ZHWLEhkr/8PM=; b=S8iLPLxGmxKFB+YdDQGrJcenWUh2+eap3hGSKbv9fRMozb40Qi3iOOqXGJMGfNnSAZ 3NfinwbLuOGlk5LGA00W4cDTCOqAEVRc5KqYwMUk8WOn+d3423eceZ0th6iPbueU437O 1yQj4L9CUxiz4lp6MET1WGVZLYSelEKkOhk9MdUopMZIR11j23RKkwbgVrCPKqAhIgjH TCcxvPyocY8Cjl+4ozO1DEXFLVVJVFiPgnyIPz3JVS/DNksCqx/B+5WF9ZVhIqEik9aD MHTYAYavMJxEorVfL+DWVsO8cDZjh5qwlVW8O4OSaWN2cIE+tjB0+Azk8tKYnU1LmKFi YxOQ== X-Gm-Message-State: AOAM530i5u0Vdf9AY7ZBd2LCx04FC/j4tkvye2kEEEGd5KcQvKf+Yo+d 9d/WrB4usqL8+f65bzPatiHIlWImisxnAT5yelLACV3bcuPyRnjjjLkwdSFbmk8CSJoc/WkbU+D 9u8QO8aQxnG1/sVftiqtQcfMtgIamAorn5qQooOP1Up9YnYQxtmyESqVLw5PxZo8vscnqOiaf70 t6olODH6QZPIM4EXlAViCMGUtLV24XSCNgKUyS X-Google-Smtp-Source: ABdhPJyME4ccbu7sUwq0ojMEF/HEcxU2W6mBXgl3Bh5iyDcVcshnTy7IPlh+xuNaXkzbhqXjET3Pkw== X-Received: by 2002:aa7:dbc1:: with SMTP id v1mr73750868edt.49.1636074602892; Thu, 04 Nov 2021 18:10:02 -0700 (PDT) Received: from [10.137.0.18] (ip-86-49-251-104.net.upcbroadband.cz. [86.49.251.104]) by smtp.gmail.com with ESMTPSA id r7sm1231316edd.5.2021.11.04.18.10.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Nov 2021 18:10:02 -0700 (PDT) Message-ID: <668dc67a-9baf-e4ab-88b0-2c39c6a2f08e@enterprisedb.com> Date: Fri, 5 Nov 2021 02:09:59 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [sqlsmith] Failed assertion in brin_minmax_multi_distance_float4 on REL_14_STABLE Content-Language: en-US From: Tomas Vondra To: Justin Pryzby , Andreas Seltenreich Cc: pgsql-hackers@postgresql.org, Jaime Casanova References: <87r1bw9ukm.fsf@credativ.de> <20211104165357.GU17618@telsasoft.com> <83b2e911-ccd9-5503-fb32-369050a6e93d@enterprisedb.com> In-Reply-To: <83b2e911-ccd9-5503-fb32-369050a6e93d@enterprisedb.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/4/21 23:56, Tomas Vondra wrote: > Hi, > > On 11/4/21 17:53, Justin Pryzby wrote: >> On Thu, Nov 04, 2021 at 09:46:49AM +0100, Andreas Seltenreich wrote: >>> sqlsmith triggers the following assertion when testing REL_14_STABLE: >>> >>>      TRAP: FailedAssertion("a1 <= a2", File: "brin_minmax_multi.c", >>> Line: 1879, PID: 631814) >>> >>> I can reproduce it with the following query on a fresh regression >>> database: >>> >>>      insert into public.brintest_multi (float4col) values (real 'nan'); >>> >>> The branch was at f6162c020c while testing, backtrace below. >> >> I couldn't reproduce this, but it reminds me of this one, which we >> also had >> trouble reproducing. >> > > I can reproduce that just fine - all I had to do was 'make installcheck' > and then connect to the regression db and run the insert. > > It seems to be a simple case of confusion in handling of NaN values. We > do sort them correctly (by calling float4_lt), but given two values > >   arg1 = nan (0x400000) >   arg2 = 0.0909090936 > > then a simple comparison does not give the expected result > >   (arg1 < arg2) >   (arg1 == arg2) >   (arg1 > arg2) > > all evaluate to false, which is why the assert fails. So I guess the > distance function for float4 (and probably float8 too) need a couple > more lines checking NaN. > Here's a patch that should fix this. It simply handled NaN and returns distance 0.0 for two NaN values and Infinity for NaN vs. something else. I did check what happens with Infinity values, but I think those are fine - we can actually calculate distance with them, and the assert works for them too. I'll improve the regression tests to include a couple NaN/Infinity cases tomorrow, and then I'll get this pushed. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company