age icon indicating copy to clipboard operation
age copied to clipboard

"where is not null" causes segmentation fault

Open dberardo-com opened this issue 1 year ago • 4 comments
trafficstars

"where is not null" statement in this query causes postgres to crash with the following error: "server process (PID 327) was terminated by signal 11: Segmentation fault"

SELECT * FROM cypher('access_control_graph', $$
    MATCH direct_group= (u:Operator {name: 'Admin'})-[:BELONGS_TO*]->(nop:Group {_type: 'NOP'})-[:PARENT_OF*]->(g2:Group)
    OPTIONAL MATCH plants=(nop)-[:RESPONSIBLE_FOR*]->(inp:Group {_type: 'PLANT'})  // subgroups
    OPTIONAL MATCH direct_assets=(nop)-[:HAS_PERMISSION*]->(r:Resource {_type: 'ASSET'}) 
    OPTIONAL MATCH indirect_assets=(inp)-[:HAS_PERMISSION*]->(r1:Resource {_type: 'ASSET'})
    where inp IS NOT NULL
    
    RETURN direct_group, 
        plants
        ,direct_assets
      //  ,indirect_assets
$$) AS (direct_group agtype, 
plants agtype 
,direct_assets agtype
--,indirect_assets agtype
);

dberardo-com avatar Sep 08 '24 13:09 dberardo-com

@dberardo-com Can you please share the following;

  • AGE version
  • Postgres version
  • Data setup we need to reproduce this bug

MuhammadTahaNaveed avatar Sep 10 '24 08:09 MuhammadTahaNaveed

i have been using the latest official docker image of age

as for the data:

SELECT drop_graph('access_control_graph',true) ;
SELECT create_graph('access_control_graph') ;


SELECT * FROM cypher('access_control_graph', $$

    MERGE (u0:Operator {name: 'Admin'})
    MERGE (u1:Operator {name: 'Operator1'})
    MERGE (u2:Operator {name: 'Operator2'})

    MERGE (g0:Group {name: 'amministratori', _type: 'NOP', role: 'ADMIN'})
    MERGE (g1:Group {name: 'supporto', _type: 'NOP'})
    MERGE (g2:Group {name: 'manutenzione_acqua', _type: 'NOP'})
    MERGE (g3:Group {name: 'manutenzione_energia', _type: 'NOP'})
    
    MERGE (g4:Group {name: 'acqua', _type: 'PLANT'})
    MERGE (g5:Group {name: 'energia', _type: 'PLANT'})

    MERGE (r1:Resource {name: 'pompa1', _type: 'ASSET'})
    MERGE (r2:Resource {name: 'pompa2', _type: 'ASSET'})
    MERGE (r3:Resource {name: 'em1', _type: 'ASSET'})
    MERGE (r4:Resource {name: 'em2', _type: 'ASSET'})
    MERGE (r5:Resource {name: 'em3', _type: 'ASSET'})

    CREATE (g0)-[:PARENT_OF]->(g1)
    CREATE (g0)-[:PARENT_OF]->(g2)
    CREATE (g0)-[:PARENT_OF]->(g3)

    CREATE (g1)-[:RESPONSIBLE_FOR]->(g4)
    CREATE (g1)-[:RESPONSIBLE_FOR]->(g5)
    CREATE (g2)-[:RESPONSIBLE_FOR]->(g4)
    CREATE (g3)-[:RESPONSIBLE_FOR]->(g5)

    CREATE (g4)-[:HAS_PERMISSION {read: true, write: true}]->(r1)
    CREATE (g4)-[:HAS_PERMISSION {read: true, write: true}]->(r2)
    CREATE (g5)-[:HAS_PERMISSION {read: true, write: true}]->(r3)
    CREATE (g5)-[:HAS_PERMISSION {read: true, write: true}]->(r4)
    CREATE (g5)-[:HAS_PERMISSION {read: true, write: true}]->(r5)

    CREATE (u0)-[:BELONGS_TO]->(g0)
    CREATE (u1)-[:BELONGS_TO]->(g1)
    CREATE (u2)-[:BELONGS_TO]->(g2)

    // CREATE (g3)-[:DENIED]->(g4)
    // CREATE (g3)-[:DENIED]->(r2)

$$) AS (path agtype);


SELECT *
FROM cypher('access_control_graph', $$
  MATCH (n)-[r]->(m)
  RETURN n, r, m
$$) AS (n agtype, r agtype, m agtype);


---

SELECT * FROM cypher('access_control_graph', $$
    MATCH direct_group= (u:Operator {name: 'Operator1'})-[:BELONGS_TO*]->(nop:Group {_type: 'NOP'}) //-[:PARENT_OF*]->(g2:Group)
    OPTIONAL MATCH plants=(nop)-[:RESPONSIBLE_FOR*]->(inp:Group {_type: 'PLANT'})  // subgroups
    OPTIONAL MATCH direct_assets=(nop)-[:HAS_PERMISSION*]->(r:Resource {_type: 'ASSET'}) 
    OPTIONAL MATCH indirect_assets=(inp)-[:HAS_PERMISSION*]->(r1:Resource {_type: 'ASSET'})
    
    RETURN direct_group
        ,plants
        ,direct_assets
        ,indirect_assets
$$) AS (
    direct_group agtype
    ,plants agtype 
    ,direct_assets agtype
    ,indirect_assets agtype
);

the last query should give you error if you use the one i have posted above instead. let me know i you can reproduce

dberardo-com avatar Sep 10 '24 08:09 dberardo-com

@dberardo-com I was able to reproduce the bug. We will look into it and update you as soon as we have a fix for it.

MuhammadTahaNaveed avatar Sep 10 '24 09:09 MuhammadTahaNaveed

This issue is stale because it has been open 60 days with no activity. Remove "Abondoned" label or comment or this will be closed in 14 days.

github-actions[bot] avatar Nov 10 '24 00:11 github-actions[bot]