Re: PostgreSQL 18 beta1 - Segmentation fault on custom type casting

From: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: Thomas Thai <thomas(dot)t(dot)thai(at)gmail(dot)com>
Subject: Re: PostgreSQL 18 beta1 - Segmentation fault on custom type casting
Date: 2025-07-10 10:59:23
Message-ID: CAJ7c6TMT93iF5F3hm8taf04JGgd6CMWGQgDqF__2EJbHR0R9OA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

> PostgreSQL 18 beta crashes with a segmentation fault when casting strings to custom types. The crash occurs specifically in PostgreSQL's type-casting system, not in extension code.
> [...]

The provided code is wrong. It doesn't work with PG17 either.

``
eax=# SELECT create_simple_type('test');
NOTICE: create_simple_type: Creating SimpleType with value 'test'
NOTICE: create_simple_type: About to return pointer 0x57ec7ef80018
with value 'test'
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
```

The reason apparently is that you are not using the varlena header.
Take a look at Jsonb implementation as an example,
src/include/utils/jsonb.h

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Laurenz Albe 2025-07-10 11:58:44 Re: Unexpected behavior when setting "idle_replication_slot_timeout"
Previous Message Fujii Masao 2025-07-10 10:27:08 Re: Unexpected behavior when setting "idle_replication_slot_timeout"