Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIyhl-0004Xg-7M for pgsql-bugs@arkaria.postgresql.org; Fri, 11 Oct 2019 17:27:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iIyhj-00058q-Rv for pgsql-bugs@arkaria.postgresql.org; Fri, 11 Oct 2019 17:27:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIyhj-00058d-7D for pgsql-bugs@lists.postgresql.org; Fri, 11 Oct 2019 17:27:51 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iIyhg-0006lI-5m for pgsql-bugs@lists.postgresql.org; Fri, 11 Oct 2019 17:27:50 +0000 Received: by mail-wm1-x343.google.com with SMTP id p7so11211171wmp.4 for ; Fri, 11 Oct 2019 10:27:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wk7B4GhIGYguZDnV0um+XyqVbmfBniXrt4kzJ6+jgho=; b=Hgy2DaZQDO1wFrg1t92HRyTvuVRIb7bxzJRrryVJ+3oKw+3b76yi2ATP2IbjeQBDAX KIDrkb1paZQ3x8LD2z8X2M6YOlC82o2nT/clrUTjDBBXsdNosqKkZyVhHxoVI8BCu5KO mE092mzEgnAxuazudCp7QFiZCXAbdMQ6YY4YDTGLrYRSmKFW5Nd8tu92AEZ2D/thg62j jFniGaGyAYJMHuvl1tTrM5vmxqBOHlM2wq7csJGlPcfYvEoh0Ey1XAk4C3opD0iPo988 17Ii5DSFiTwdueOLSty91OFUX2geHlXS4Udp8hGYEnDGMZX6BKi717vl9xxNJHfmJqQ+ wk/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wk7B4GhIGYguZDnV0um+XyqVbmfBniXrt4kzJ6+jgho=; b=oT20HZ6omg4u5/Xh8dJyop5tLnyTAXXgOH2Z1ajFCLhonDA+CocwJUkC4IGmV283lI 6IUgN1/+U3NJIFSZUgUm/zrmwWdSATxMHORVpKG+qXVg/V0XU4qak/lIiZTAUIPUv4WY mDfNG8Z2GPmQfxsiE1+W7kCafGirD0uT0SMtl1d9t+WBy+KDyEl8vPS78N78vKA/qKxX nZ95TwUqAxzIZG5jPkSwwVqvqMmmftNcjBUWXS9c1fzJQ6iM5ZCGCK/2MVLdtQNj3OL6 BtMeV46FSrKp5/aG7vUGQjiTevko3Wec09+yYHGteyHqtp6w9WMgBqwAXuWgQV80E4Ib Dizg== X-Gm-Message-State: APjAAAXoRPXdkoQaXMSoK+r6bwmJTZtm4n4wcf3cro5CbyNpb8HxNWyM 31mn9ZUB7pnHU5dYAZlF1Jl1jg== X-Google-Smtp-Source: APXvYqw/8tkm1ZWsYFyVzs1K/6POiT1mhqagUqVmlXb8KNayIKNaMyFSLk9xicLXvIYenwW98kTpzQ== X-Received: by 2002:a1c:9894:: with SMTP id a142mr3954185wme.135.1570814866468; Fri, 11 Oct 2019 10:27:46 -0700 (PDT) Received: from localhost (ip-86-49-253-183.net.upcbroadband.cz. [86.49.253.183]) by smtp.gmail.com with ESMTPSA id w9sm14671974wrt.62.2019.10.11.10.27.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2019 10:27:41 -0700 (PDT) Date: Fri, 11 Oct 2019 19:27:39 +0200 From: Tomas Vondra To: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16050: Server crash on CREATE TEXT SEARCH DICTIONARY with a wrong AffFile Message-ID: <20191011172739.gyim55av2dfr2xac@development> References: <16050-024ae722464ab604@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <16050-024ae722464ab604@postgresql.org> User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Oct 11, 2019 at 03:05:38PM +0000, PG Bug reporting form wrote: >The following bug has been logged on the website: > >Bug reference: 16050 >Logged by: Alexander Lakhin >Email address: exclusion@gmail.com >PostgreSQL version: 12.0 >Operating system: Ubuntu 18.04 >Description: > >The following query: >CREATE TEXT SEARCH DICTIONARY hunspell_num (Template=ispell, >DictFile=hunspell_sample_num, AffFile=hunspell_sample_long); > >crashes postgres with the stack trace: >Core was generated by `postgres: law regression [local] CREATE TEXT SEARCH >DICTIONARY '. Yep, I can reproduce it quite easily. With extra debug symbols and memory randomization it produces a bit clearer backtrace: Program received signal SIGSEGV, Segmentation fault. 0x00000000008fd31b in getCompoundAffixFlagValue (Conf=0x2d053c8, s=0x7f7f7f7f7f7f7f7f ) at spell.c:1126 1126 while (*flagcur) (gdb) bt #0 0x00000000008fd31b in getCompoundAffixFlagValue (Conf=0x2d053c8, s=0x7f7f7f7f7f7f7f7f ) at spell.c:1126 #1 0x00000000008fe627 in makeCompoundFlags (Conf=0x2d053c8, affix=303) at spell.c:1608 #2 0x00000000008fe959 in mkSPNode (Conf=0x2d053c8, low=0, high=1, level=3) at spell.c:1680 #3 0x00000000008fea1e in mkSPNode (Conf=0x2d053c8, low=0, high=1, level=2) at spell.c:1692 #4 0x00000000008fe794 in mkSPNode (Conf=0x2d053c8, low=0, high=4, level=1) at spell.c:1652 #5 0x00000000008fe794 in mkSPNode (Conf=0x2d053c8, low=0, high=9, level=0) at spell.c:1652 ... That is, makeCompontFlags calls getCompoundAffixFlagValue with invalid pointer 's', likely after it got already pfreed. cheers -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services