I had similar issue recently. This could be caused by a recursive function call entering an endless loop. In my case checking the code and defining in the problematic function a limit for the depth of recursive calls solved the issue.
Franck Theeten ________________________________ From: Michal Seidl <[email protected]> Sent: Wednesday, June 18, 2025 11:36 To: [email protected] <[email protected]> Subject: Topology - toTopoGeom causes segmentation fault and database restart Hello, we use postgis topology for storing and updating quite complicated polygons representing roads. Sometimes inserting new polygon into topology causes exceptions (whis is not nice but acceptable, I can see there is plan to add some more usefull message https://trac.osgeo.org/postgis/ticket/5889) but sometimes it completely shut down server which is quite bad as there are other live databases on server. The error is cause by our function jt_to_topo_geom() which is just wrapper about toTopoGeom(). The inserted MultiPolygon geometry is quite large but postgis valid with reasonable vertices. I have suspicion there is conflict with data already inserted into topology, but have no idea where due to not info from log. Postgis: POSTGIS="3.4.2 c19ce56" [EXTENSION] PGSQL="140" GEOS="3.9.0-CAPI-1.16.2" PROJ="7.2.1 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/tmp/proj DATABASE_PATH=/usr/share/proj/proj.db" LIBXML="2.9.10" LIBJSON="0.15" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)" TOPOLOGY The code of function: CREATE OR REPLACE FUNCTION unis_emh.jt_to_topo_geom( dst_schema character varying, dst_table character varying, dst_column character varying, geom geometry) RETURNS topogeometry LANGUAGE 'plpgsql' COST 100 VOLATILE PARALLEL UNSAFE AS $BODY$ DECLARE layer_ layer; topology_ topology; BEGIN -- get names SELECT * FROM FindLayer(dst_schema, dst_table, dst_column) INTO layer_; SELECT * FROM FindTopology((layer_).topology_id) INTO topology_; -- insert geometry, no duplicate protection RETURN toTopoGeom(geom, (topology_).name, (layer_).layer_id); END; $BODY$; Database log: 2025-06-17 17:41:46.509 CET [2414906] LOG: server process (PID 2415005) was terminated by signal 11: Segmentation fault 2025-06-17 17:41:46.509 CEST [2414906] DETAIL: Failed process was running: INSERT INTO "j_pmh_topo_geometrie" ("id_geometrie", "topo_geom") SELECT "id_geometrie", "unis_emh"."jt_to_topo_geom"(current_schema::text, 'j_pmh_topo_geometrie', 'topo_geom', "geom") FROM "j_pmh_geometrie" WHERE "id_geometrie"=63855 2025-06-17 17:41:46.509 CEST [2414906] LOG: terminating any other active server processes 2025-06-17 17:41:46.513 CEST [2414906] LOG: all server processes terminated; reinitializing 2025-06-17 17:41:46.625 CEST [2415006] LOG: database system was interrupted; last known up at 2025-06-17 17:40:42 CEST 2025-06-17 17:41:46.896 CEST [2415006] LOG: database system was not properly shut down; automatic recovery in progress 2025-06-17 17:41:46.917 CEST [2415006] LOG: redo starts at 14F/64BCDA20 2025-06-17 17:41:46.927 CEST [2415006] LOG: unexpected pageaddr 14F/20000000 in log segment 000000010000014F00000065, offset 0 2025-06-17 17:41:46.927 CEST [2415006] LOG: redo done at 14F/64FFFFC0 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.01 s 2025-06-17 17:41:47.021 CEST [2414906] LOG: database system is ready to accept connections MS.
