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 1n8Dux-0005ix-87 for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Jan 2022 04:10:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n8DuO-0000FC-Nt for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Jan 2022 04:09:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n8DuO-0000F3-6S for pgsql-hackers@lists.postgresql.org; Fri, 14 Jan 2022 04:09:48 +0000 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n8DuL-0002iq-HD for pgsql-hackers@postgresql.org; Fri, 14 Jan 2022 04:09:46 +0000 Received: by mail-qk1-x72c.google.com with SMTP id z10so5407423qkf.7 for ; Thu, 13 Jan 2022 20:09:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=iUuHGfWH1s+mkSYKCj3nhhROgryJe2vigEeZxAfaWnY=; b=JevzPHSVs23D1p1upKlc/Zq5MtZbjbq/iykDAF/WiJa/30mwWmbOLDviBwT39hszGc R/F6xHCALiTVBrqanm5YrByMiWwVZH5hernBiEIW7Xa6Js30Jr09rzaaAp3EFT0oBiMc lL+V4bbN+DrFHAUkTXDOlW+ItwWsXVa7/F9PU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=iUuHGfWH1s+mkSYKCj3nhhROgryJe2vigEeZxAfaWnY=; b=JGE8mmQWHzwQUyXYz11+r2e46C6+JfQyqog+F/E55PeogRBYHmRYsiIg7WnvVow2E+ UQwpPsjuKabWbKs+EnHZT/ktG1ergNqCWrN88eSlrpjNZ/coBHInrXJbBW6wkAOfZt5A C8KIHgFUcL1qWGgwrh1R9+9nx24vFDjnhq4HhcL5P9Y8sVQcIEe7w7ZSYbeRBVMXvseH ezH8ksRz05orF1noXZVLlmMSTBC//9VwuUtfdhlr8CDTjGPU+wZ5ym3lq7kcBVyZqlgY +rTl3McxY89X8K8gMCw4q/86paoiNDRJa4EQkUMu5e3Q+wZeOtO+4saWkRuamE/BjtzD rL/A== X-Gm-Message-State: AOAM533IBic/sDpLwEF2YonxS7Ky37aIbcMKHoDIgLjrM+p1fh+VSuqJ rsO2oySN2a00LotKoKEnJkRcr8fINfJurtyB X-Google-Smtp-Source: ABdhPJy0psOzxV4P/d3WwoILHGgfocONqlf5oHIADHCDF2q9yIsieWM0m+4AkUMpkW/2LXuZ0/zM1Q== X-Received: by 2002:a37:bf04:: with SMTP id p4mr5320459qkf.724.1642133384358; Thu, 13 Jan 2022 20:09:44 -0800 (PST) Received: from rfd.leadboat.com ([2600:1702:a20:5750::2e]) by smtp.gmail.com with ESMTPSA id y8sm3144065qtx.74.2022.01.13.20.09.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jan 2022 20:09:43 -0800 (PST) Date: Thu, 13 Jan 2022 20:09:40 -0800 From: Noah Misch To: Zhihong Yu Cc: Tom Lane , PostgreSQL-development Subject: Re: null iv parameter passed to combo_init() Message-ID: <20220114040940.GA447185@rfd.leadboat.com> References: <20220109015202.GB283924@rfd.leadboat.com> <20220109031100.GC283924@rfd.leadboat.com> <1643134.1641713553@sss.pgh.pa.us> <20220109164854.GA309234@rfd.leadboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, Jan 09, 2022 at 06:45:09PM -0800, Zhihong Yu wrote: > On Sun, Jan 9, 2022 at 1:27 PM Zhihong Yu wrote: > > After installing gcc-11, ./configure passed (with 0003-memcpy-null.patch). > > In the output of `make check-world`, I don't see `runtime error`. That's expected. With -fsanitize-undefined-trap-on-error, the program will generate SIGILL when UBSan detects undefined behavior. To get "runtime error" messages in the postmaster log, drop -fsanitize-undefined-trap-on-error. Both ways of running the tests have uses. -fsanitize-undefined-trap-on-error is better when you think the code is clean, because a zero "make check-world" exit status confirms the code is clean. Once you know the code is unclean in some way, -fsanitize-undefined-trap-on-error is better for getting details. > > Though there was a crash (maybe specific to my machine): > > > > Core was generated by > > `/nfusr/dev-server/zyu/postgres/tmp_install/usr/local/pgsql/bin/postgres > > --singl'. > > Program terminated with signal SIGILL, Illegal instruction. > > #0 0x000000000050642d in write_item.cold () > > Missing separate debuginfos, use: debuginfo-install > > glibc-2.17-325.el7_9.x86_64 nss-pam-ldapd-0.8.13-25.el7.x86_64 > > sssd-client-1.16.5-10.el7_9.10.x86_64 > > (gdb) bt > > #0 0x000000000050642d in write_item.cold () > > #1 0x0000000000ba9d1b in write_relcache_init_file () > > #2 0x0000000000bb58f7 in RelationCacheInitializePhase3 () > > #3 0x0000000000bd5cb5 in InitPostgres () > > #4 0x0000000000a0a9ea in PostgresMain () That is UBSan detecting undefined behavior. A successful patch version will fix write_item(), among many other places that are currently making check-world fail. I get the same when testing your v5 under "gcc (Debian 11.2.0-13) 11.2.0". I used the same host as buildfarm member thorntail, and I configured like this: ./configure -C --with-lz4 --prefix=$HOME/sw/nopath/pghead --enable-tap-tests --enable-debug --enable-depend --enable-cassert CC='ccache gcc-11 -fsanitize=undefined -fsanitize-undefined-trap-on-error' CFLAGS='-O2 -funwind-tables' > Earlier I was using devtoolset-11 which had an `Illegal instruction` error. > > I compiled / installed gcc-11 from source (which took whole afternoon). > `make check-world` passed with patch v3. > In tmp_install/log/install.log, I saw: > > gcc -Wall -Wmissing-prototypes -Wpointer-arith > -Wdeclaration-after-statement -Werror=vla -Wendif-labels > -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type > -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard > -Wno-format-truncation -Wno-stringop-truncation -fsanitize=undefined > -fsanitize-undefined-trap-on-error -I../../src/port -DFRONTEND > -I../../src/include -D_GNU_SOURCE -c -o path.o path.c > rm -f libpgport.a Perhaps this self-compiled gcc-11 is defective, being unable to detect the instances of undefined behavior that other builds detect. If so, use the "devtoolset-11" gcc instead. You're also building without optimization; that might be the problem.