Skip to content

data.table 1.18.0 causes Postgresql server crash (segmentation fault) with pl/R on Debian servers #7605

@ced75

Description

@ced75

Since version 1.18.0, loading data.table in a pl/R function on a PostgreSQL server on Debian (12 and 13 at least) causes a segmentation fault which crashes the PostgreSQL instance (17 and 18 tested).

Steps to reproduce on a fresh Debian (12 or 13) VM:

Install PostgreSQL

sudo apt update
sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
sudo apt install postgresql-17

Install R

sudo apt install r-base r-base-dev

Install R packages

To be usable by PostgreSQL, packages are installed as sudo.

sudo R
install.packages(c("dplyr", "data.table"))
exit

data.table v 1.18.0 is installed by default, since it's the last available version.

Install pl/R

sudo apt install postgresql-17-plr

Create and test a pl/R function loading data.table

sudo -iu postgres psql
create extension plr;

SELECT * FROM plr_environ();
SELECT load_r_typenames();
SELECT * FROM r_typenames();
SELECT plr_array_accum('{23,35}', 42);

CREATE OR REPLACE FUNCTION public.r_test(int) RETURNS int AS $code$
    library(data.table)
    return(arg1)
$code$ LANGUAGE 'plr' STRICT;

select * from public.r_test(1);

The PostgreSQL server crashes with a segmentation fault caused by the r_test function call. If you comment the data.table loading, the function works fine.

In R, data.table loading works fine, the problem is only related to pl/R in PostgreSQL.
If you replace data.table v 1.18.0 by v 1.17.8 (or earlier), everything works fine.

On an Ubuntu Server 24.04, the problem does not occur.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions