Various crashes with invalid ontologies.
Here are some examples of bad ontologies that cause crashes in libtracker-sparql.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix nautilus: <https://gitlab.gnome.org/GNOME/nautilus#> .
@prefix tracker: <http://tracker.api.gnome.org/ontology/v3/tracker#> .
nautilus: a tracker:Namespace, tracker:Ontology ;
tracker:prefix "nautilus" ;
tracker:lastModified "2020-05-01T10:00:00Z" .
nautilus:FileReference a rdfs:Class ;
rdfs:comment "..." ;
rdfs:subClassOf rdfs:Resource .
nautilus:starred a rdf:Property ;
rdfs:comment "Marks resources that are starred in Nautilus." ;
rdfs:domain Nautilus:File ; # this is invalid
rdfs:range xsd:boolean .
This triggers a crash here:
#0 0x00007ffff7e70b6a in __strlen_sse2 () at /lib64/libc.so.6
#1 0x00007ffff570f599 in tracker_data_ontology_process_statement
(manager=0x5555559a8440 [TrackerDataManager], subject=0x555555a8b850 "https://gitlab.gnome.org/GNOME/nautilus#starred", predicate=0
x555555a78e20 "http://www.w3.org/2000/01/rdf-schema#domain", object=0x0, in_update=0)
at ../subprojects/tracker/src/libtracker-data/tracker-data-manager.c:1997
#2 0x00007ffff570f723 in import_ontology_file (manager=0x5555559a8440 [TrackerDataManager], file=0x5555559b0820, in_update=0)
at ../subprojects/tracker/src/libtracker-data/tracker-data-manager.c:2040
#3 0x00007ffff5714523 in tracker_data_manager_initable_init (initable=0x5555559a8440, cancellable=0x0, error=0x7fffffffd478)
at ../subprojects/tracker/src/libtracker-data/tracker-data-manager.c:4201
#4 0x00007ffff57d86a5 in tracker_direct_connection_initable_init (initable=0x5555559a6790, cancellable=0x0, error=0x7fffffffd538)
at ../subprojects/tracker/src/libtracker-direct/tracker-direct.c:303
#5 0x00007ffff57bd05f in tracker_sparql_connection_new
(flags=TRACKER_SPARQL_CONNECTION_FLAGS_NONE, store=0x5555559b0f20, ontology=0x5555559b0f40, cancellable=0x0, error=0x7fffffffd788)
Another example of a malformed ontology:
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix nautilus: <https://gitlab.gnome.org/GNOME/nautilus#> .
@prefix tracker: <http://tracker.api.gnome.org/ontology/v3/tracker#> .
nautilus: a tracker:Namespace, tracker:Ontology ;
tracker:prefix "nautilus" ;
tracker:lastModified "2020-05-01T10:00:00Z" .
nautilus:FileReference a rdf:Class ; # should be rdfs:Class
rdfs:comment "..." ;
rdfs:subClassOf rdfs:Resource .
nautilus:starred a rdf:Property ;
rdfs:comment "Marks resources that are starred in Nautilus." ;
rdfs:domain nautilus:File ;
rdfs:range xsd:boolean .
This causes various warnings and criticals:
(process:21195): Tracker-CRITICAL **: 20:13:38.173: file:///opt/tracker3/share/nautilus/ontology/nautilus.ontology: Unknown class https://gitlab.gnome.org/GNOME/nautilus#FileReference
(process:21195): Tracker-CRITICAL **: 20:13:38.173: tracker_ontologies_get_class_by_uri: assertion 'class_uri != NULL' failed
(process:21195): Tracker-CRITICAL **: 20:13:38.173: file:///opt/tracker3/share/nautilus/ontology/nautilus.ontology: Unknown class (null)
(process:21195): Tracker-CRITICAL **: 20:13:38.218: Class 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Class' not found in the ontology
(process:21195): Tracker-CRITICAL **: 20:13:38.218: Subject `https://gitlab.gnome.org/GNOME/nautilus#FileReference' is not in domain `rdfs:Resource' of property `rdfs:comment'
(process:21195): Tracker-CRITICAL **: 20:13:38.218: Subject `https://gitlab.gnome.org/GNOME/nautilus#FileReference' is not in domain `rdfs:Class' of property `rdfs:subClassOf'
fish: “env TRACKER_DEBUG=sparql ./naut…” terminated by signal SIGSEGV (Address boundary error)
Another ontology that triggers a crash:
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix nrl: <http://tracker.api.gnome.org/ontology/v3/nrl#> .
@prefix nautilus: <https://gitlab.gnome.org/GNOME/nautilus#> .
nautilus: a nrl:Namespace, nrl:Ontology ;
nrl:prefix "nautilus" ;
nrl:lastModified "2020-05-01T10:00:00Z" .
nautilus:File a rdfs:Class ;
rdfs:comment "Represents a file on disk by its URL. Equivalent to http://tracker.api.gnome.org/ontology/v3/nfo#FileDataObject" ;
rdfs:subClassOf rdfs:Resource .
nautilus:starred a rdf:Property ;
rdfs:comment "Marks files that are starred in Nautilus." ;
rdfs:domain nfo:FileDataObject ; # should be nautilus:File
rdfs:range xsd:boolean .
Triggers a critical here:
(org.gnome.Nautilus:295067): Tracker-CRITICAL **: 14:11:50.716: tracker_ontologies_get_class_by_uri: assertion 'class_uri != NULL' failed
Edited by Sam Thursfield