apache / apache/age

Server crashes (segfault) on `cypher(CREATE ...)` inside SQL `WHERE NOT EXISTS` with a nested `cypher(MATCH ...)` subquery

Open
#2,501 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
C
Stars
4.8k
Forks
523
Avg merge
1d 2h
Merged PRs (30d)
9

Description

**Bug description**

Writing a Cypher `CREATE` in the outer query of a `SELECT ... WHERE NOT EXISTS (...)` statement, where the `NOT EXISTS` subquery contains another `cypher(MATCH ...)` call, crashes the PostgreSQL backend with a segmentation fault. The backend process is terminated (`signal 11: Segmentation fault`) and the connection is dropped.

**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:

```pgsql
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**

```pgsql
SELECT * FROM cypher('graph_test', $$ CREATE () $$) AS (a agtype)
WHERE NOT EXISTS (SELECT * FROM cypher('graph_test', $$ MATCH () RETURN 1 $$) AS (b agtype));
```

```
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
The connection to the server was lost. Attempting reset: Failed.
Time: 2171.760 ms (00:02.172)
```

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 statement is a legal combination of two individually-valid Cypher queries glued together with SQL's `WHERE NOT EXISTS`. It should either execute normally (creating the node and returning a row) or raise a normal SQL error — it must not crash the backend process.

**Environment**

- Version: 1.8.0 (official `apache/age:1.8.0` Docker image)
- PostgreSQL: 18.1 (Debian 18.1-1.pgdg13+2), x86_64

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash with psql in the official apache/age:1.8.0 Docker container using the provided graph setup and nested cypher query. Compare the observed backend termination with the expected normal execution or SQL error; the issue names no source files or tests, so locating the failing PostgreSQL extension path will require repository research.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, postgresql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.