Re: PostgreSQL 18 beta1 - Segmentation fault on custom type casting - Mailing list pgsql-bugs

From Aleksander Alekseev
Subject Re: PostgreSQL 18 beta1 - Segmentation fault on custom type casting
Date
Msg-id CAJ7c6TMT93iF5F3hm8taf04JGgd6CMWGQgDqF__2EJbHR0R9OA@mail.gmail.com
Whole thread Raw
In response to PostgreSQL 18 beta1 - Segmentation fault on custom type casting  (Thomas Thai <thomas.t.thai@gmail.com>)
List pgsql-bugs
Hi,

> PostgreSQL 18 beta crashes with a segmentation fault when casting strings to custom types. The crash occurs
specificallyin 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



pgsql-bugs by date:

Previous
From: Fujii Masao
Date:
Subject: Re: Unexpected behavior when setting "idle_replication_slot_timeout"
Next
From: Laurenz Albe
Date:
Subject: Re: Unexpected behavior when setting "idle_replication_slot_timeout"