Re: BUG #19595: Three memory-safety defects in src/backend/tsearch/spell.c (dictionary loader), PG 18.3

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com>, michaelmalis2(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19595: Three memory-safety defects in src/backend/tsearch/spell.c (dictionary loader), PG 18.3
Date: 2026-08-30 04:00:00
Message-ID: 2ab10d25-7dc6-4914-8aea-ca0adfbe57c3@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello Tom,

02.08.2026 23:11, Tom Lane wrote:
> Hmph. Not sure I'd call that "memory safety", but yeah, this bit
> isn't being careful about having a valid intermediate state of the
> data structure. Thanks for the report!

I discovered one more issue in this area. This OOM condition emulation:
--- a/src/backend/snowball/libstemmer/api.c
+++ b/src/backend/snowball/libstemmer/api.c
@@ -6,3 +6,3 @@ extern struct SN_env * SN_new_env(int alloc_size)
 {
-    struct SN_env * z = (struct SN_env *) malloc(alloc_size);
+    struct SN_env * z = (rand() % 2 == 0) ? NULL : (struct SN_env *) malloc(alloc_size);
     if (z == NULL) return NULL;

leads to `make check` crashes like:
2026-08-30 06:42:24.759 EEST postmaster[1423557] LOG:  client backend (PID 1423766) was terminated by signal 11:
Segmentation fault
2026-08-30 06:42:24.759 EEST postmaster[1423557] DETAIL:  Failed process was running: SELECT
ts_delete(to_tsvector('english', 'Rebel spaceships, striking from a hidden base'), 'spaceship')
or
2026-08-30 06:46:50.112 EEST postmaster[1426347] LOG:  client backend (PID 1427391) was terminated by signal 11:
Segmentation fault
2026-08-30 06:46:50.112 EEST postmaster[1426347] DETAIL:  Failed process was running: SELECT ts_lexize('thesaurus', 'one');

Could you please have a look if you're still around?

Best regards,
Alexander

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2026-08-30 04:04:07 Re: BUG #19595: Three memory-safety defects in src/backend/tsearch/spell.c (dictionary loader), PG 18.3
Previous Message Andrey Rachitskiy 2026-08-30 03:08:19 Re: BUG #19487: Error while executing SQL query involving XML parsing