BenSpex commented on issue #2474:
URL: https://github.com/apache/age/issues/2474#issuecomment-4936579834

   **Root cause found + fix PR opened: #2475.**
   
   Correction to the repro above: the crash requires the edge-label policy qual 
to call a **SQL-language function** (e.g. a `STABLE` tenant-accessor wrapping 
the property lookup). The inline constant qual as written above may NOT crash — 
a constant-only qual never dispatches into `fmgr_sql`. Replace the `E` policy 
with:
   
   ```sql
   CREATE FUNCTION current_tid() RETURNS agtype LANGUAGE sql STABLE AS $$ 
SELECT '"x"'::agtype $$;
   CREATE POLICY p ON g."E" FOR ALL TO rls_user
     USING      (ag_catalog.agtype_access_operator(properties, '"tid"'::agtype) 
= current_tid())
     WITH CHECK (ag_catalog.agtype_access_operator(properties, '"tid"'::agtype) 
= current_tid());
   ```
   
   **Mechanism:** `check_for_connected_edges()` runs from `end_cypher_delete()` 
during executor teardown (`PortalCleanup`) — after the portal's active snapshot 
has been popped. Evaluating the connected-edge RLS quals there 
(`check_security_quals` → `ExecQual`) dispatches into 
`fmgr_sql`/`postquel_start` when the qual contains a SQL function, which needs 
an active snapshot → `GetActiveSnapshot()` NULL-deref → SIGSEGV. Verified on 
`release_PG18_1.7.0` and current master; also A/B-verified on a release-style 
build (-O2, cassert off): unpatched segfaults, patched (#2475, pushes 
`estate->es_snapshot` for the duration of the scan) deletes cleanly. Full 
`installcheck` green incl. a new regression test in `regress/sql/security.sql`.


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