hkjiang26 opened a new issue, #2506:
URL: https://github.com/apache/age/issues/2506

   ## Bug description
   
   Writing a Cypher `CREATE` that creates a relationship whose start/end vertex 
is `NULL` — a value produced by an `OPTIONAL MATCH` that matched nothing — 
crashes the PostgreSQL backend with a segmentation fault. The backend process 
is terminated (`signal 11: Segmentation fault`) and the connection is dropped. 
Instead of raising a normal error for a NULL endpoint, AGE 1.8.0 dereferences 
the NULL vertex and crashes.
   
   ## Access method
   
   - Command line via `psql`, inside the official Docker container 
`apache/age:1.8.0`
   
   ## Data setup
   
   One graph with a single node. No edges.
   
   ```pgsql
   CREATE EXTENSION IF NOT EXISTS age;
   LOAD 'age';
   SET search_path = ag_catalog, "$user", public;
   SELECT create_graph('graph_test');
   SELECT * FROM cypher('graph_test', $$ CREATE (a:Node {name: 'A'}) $$) AS (c0 
agtype);
   ```
   
   ## 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', $$ MATCH (a:Node {name: 'A'}) OPTIONAL 
MATCH (a)-[:LINK_TO]->(c) CREATE (a)-[:LINK_TO]->(c) $$) AS (c0 agtype);
   ```
   
   The `OPTIONAL MATCH` does not match (no `LINK_TO` edge exists), so `c` is 
bound to `NULL`; the subsequent `CREATE (a)-[:LINK_TO]->(c)` then tries to 
create a relationship whose endpoint is `NULL`.
   
   ```
   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 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
   
   `OPTIONAL MATCH` implements a left join: when the pattern does not match, 
its variables are bound to `NULL`. The query is legal Cypher and should either 
execute normally, or raise a normal Cypher error (e.g., "endpoint is null") — 
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
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to