pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Geier <geidav.pg@gmail.com>
To: Chris St Denis <chris@ctgameinfo.com>
To: pgsql-bugs@lists.postgresql.org
Subject: Re: crash in ltree_compare_distance() in 14.24
Date: Wed, 28 Oct 2026 20:19:59 +0100
Message-ID: <23946400-3809-499d-b0bc-5f859df8ef50@gmail.com> (raw)
In-Reply-To: <3527d5c4-0ce4-4412-b433-2e1d36517139@ctgameinfo.com>
References: <043a5139-1f0c-49df-b423-1cd129839aa9@ctgameinfo.com>
	<497fe0b6-2f8c-4237-b749-bed21de36c01@gmail.com>
	<3527d5c4-0ce4-4412-b433-2e1d36517139@ctgameinfo.com>

>> In case you cannot reproduce it, can you share at least the query you
>> were running and the relevant parts of the schema?
> 
> It happened in the middle of the night, has not happened since.
> 
> The ltree column id_tree contains a ltree of comment ID's showing the
> tree of comment replies.
> 
> Logs show this
> 
>      2026-10-26 02:26:35.914 PDT [61206] LOG:  server process (PID
>    50023) was terminated by signal 11: Segmentation fault
>      2026-10-26 02:26:35.914 PDT [61206] DETAIL:  Failed process was
>    running: INSERT INTO "story_comments" ("comment", "reply_to",
>    "deleted", "id_tree", "sid", "user_id", "ipaddr") VALUES ($1, $2,
>    $3, $4, $5, $6, $7)
> 
> Due to parameterised queries, I do not have the data values that were
> inserted.
> 
> Here is the table structure.
Thanks for sharing the details.

What can be concluded from the core dump information you shared in your
first mail is that the read of b->numlevel in

float
ltree_compare_distance(const ltree *a, const ltree *b)
{
	ltree_level *al = LTREE_FIRST(a);
	ltree_level *bl = LTREE_FIRST(b);
	int			an = a->numlevel;
	int			bn = b->numlevel;

causes the segfault, likely because "b" is a corrupted pointer. The
value of b is 0x127a2f2a13, which is unaligned and far away from "a"
which is 0x2fa39243b1d8 and aligned as expected. Beyond that, the "a"
ltree is empty / has 0 levels as can be inferred from edx = 0.

I tried to create a failing test case based on your schema details but
failed. I'm assuming that the order of INSERTs and the data matters.

What you could try is open your core dump and go down the call stack to
see where "b" gets messed up. It would also be interesting which of the
two calls to ltree_compare_distance() in ltree_penalty() causes the
segfault.

Do you use data checksums? If not, maybe the issue stems from a data
corruption on disk?

FYI: PostgreSQL 14 reaches end of life on November 12, 2026. Though, I
think it's not unlikely that this bug is also on master.

-- 
David Geier






view thread (6+ messages)  latest in thread

Message-ID: <23946400-3809-499d-b0bc-5f859df8ef50@gmail.com>
Permalink:  ../23946400-3809-499d-b0bc-5f859df8ef50@gmail.com/
Also on:    postgresql.org/message-id/23946400-3809-499d-b0bc-5f859df8ef50@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: geidav.pg@gmail.com, chris@ctgameinfo.com
  Subject: Re: crash in ltree_compare_distance() in 14.24
  In-Reply-To: <23946400-3809-499d-b0bc-5f859df8ef50@gmail.com>
  References: <043a5139-1f0c-49df-b423-1cd129839aa9@ctgameinfo.com> <497fe0b6-2f8c-4237-b749-bed21de36c01@gmail.com> <3527d5c4-0ce4-4412-b433-2e1d36517139@ctgameinfo.com> <23946400-3809-499d-b0bc-5f859df8ef50@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox