Bug description
Writing a Cypher query in which a write clause (CREATE, MERGE, or SET) is followed by a WITH projection whose WHERE clause contains an EXISTS { } subquery crashes the PostgreSQL backend with a segmentation fault. The backend process is terminated (signal 11: Segmentation fault) and the connection is dropped. The crash happens even when the EXISTS subquery is empty and does not reference any outer variable, and even when the created vertex is not carried through the WITH.
Access method
- Command line via
psql, inside the official Docker container apache/age:1.8.0
Data setup
No data is required — the crash reproduces on an empty graph. Only the graph itself must exist:
CREATE EXTENSION IF NOT EXISTS age;
LOAD 'age';
SET search_path = ag_catalog, "$user", public;
SELECT create_graph('graph_test');
Configuration
- None beyond the stock AGE extension. No additional modules (no PostGIS, etc.), default
search_path handling as shown above.
Command that triggers the crash
SELECT * FROM cypher('graph_test', $$ CREATE (a) WITH a WHERE exists { RETURN 1 } RETURN 1 $$) AS (c0 agtype);
The CREATE writes a single vertex, the WITH carries it forward, and the WHERE's EXISTS subquery always yields one row. Any one of the following also crashes: using MERGE (a) or MATCH (a) SET a.x = 1 instead of CREATE (a); using WITH * or dropping a from the projection (CREATE (a) WITH 1 AS x); replacing the subquery body with WITH a or RETURN a.
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
connection to server was lost
The server log shows the backend being killed:
LOG: client backend (PID NNN) was terminated by signal 11: Segmentation fault
LOG: terminating any other active server processes
LOG: all server processes terminated; reinitializing
Expected behavior
The query is valid Cypher: a write clause, a WITH projection, and an EXISTS subquery in a WHERE clause are all standard, and the subquery always returns one row. It should either execute normally or raise a normal Cypher error — it must not crash the backend process. Notably, the same EXISTS subquery in a WHERE attached to a pure read clause (e.g. MATCH (a) WHERE exists { RETURN 1 } RETURN 1) or in a RETURN projection (e.g. RETURN exists { RETURN 1 }) executes correctly; the crash is specific to the combination of a write clause feeding the WITH whose WHERE contains the EXISTS.
Environment
- Version: 1.8.0 (official
apache/age:1.8.0 Docker image)
- PostgreSQL: 18.1 (Debian 18.1-1.pgdg13+2), x86_64
Bug description
Writing a Cypher query in which a write clause (
CREATE,MERGE, orSET) is followed by aWITHprojection whoseWHEREclause contains anEXISTS { }subquery crashes the PostgreSQL backend with a segmentation fault. The backend process is terminated (signal 11: Segmentation fault) and the connection is dropped. The crash happens even when theEXISTSsubquery is empty and does not reference any outer variable, and even when the created vertex is not carried through theWITH.Access method
psql, inside the official Docker containerapache/age:1.8.0Data setup
No data is required — the crash reproduces on an empty graph. Only the graph itself must exist:
Configuration
search_pathhandling as shown above.Command that triggers the crash
The
CREATEwrites a single vertex, theWITHcarries it forward, and theWHERE'sEXISTSsubquery always yields one row. Any one of the following also crashes: usingMERGE (a)orMATCH (a) SET a.x = 1instead ofCREATE (a); usingWITH *or droppingafrom the projection (CREATE (a) WITH 1 AS x); replacing the subquery body withWITH aorRETURN a.The server log shows the backend being killed:
Expected behavior
The query is valid Cypher: a write clause, a
WITHprojection, and anEXISTSsubquery in aWHEREclause are all standard, and the subquery always returns one row. It should either execute normally or raise a normal Cypher error — it must not crash the backend process. Notably, the sameEXISTSsubquery in aWHEREattached to a pure read clause (e.g.MATCH (a) WHERE exists { RETURN 1 } RETURN 1) or in aRETURNprojection (e.g.RETURN exists { RETURN 1 }) executes correctly; the crash is specific to the combination of a write clause feeding theWITHwhoseWHEREcontains theEXISTS.Environment
apache/age:1.8.0Docker image)