Stack overflow in simple piece of code

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Stack overflow in simple piece of code

Conrad
I have a really simple piece of code but it already runs into an error. My piece of code
should just iterate over the class names in an ontology and print them out. This works for the first 20 or
so, but then this error occurs:

Fatal Python error: Cannot recover from stack overflow.

Current thread 0x0000000106d2ae00 (most recent call first):
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/util.py", line 249 in __enter__
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 543 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 540 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 538 in _get_by_storid
  File "/Users/PATH/.env/lib/python3.7/site-packages/owlready2/namespace.py", line 558 in _load_by_storid
  ...
[1]    51983 abort      python owl_to_nodenames.py

My simple code is:

from owlready2 import get_ontology
onto = get_ontology("Ontologie.owl").load()
for this in onto.classes():
    print(this)

Can you point me to the error? I originally tried it on a MacBook, but now I also tested it on a computer running Arch, same error.
Reply | Threaded
Open this post in threaded view
|

Re: Stack overflow in simple piece of code

Conrad
Update: There probably is a cycle in my ontology but this shouldn't lead to a recursion error - I believe, as Cycles are acceptable in ontologies.
Reply | Threaded
Open this post in threaded view
|

Re: Stack overflow in simple piece of code

Jiba
Administrator
Hi,

On which ontology are you trying your code? Could you send it to me please?

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Stack overflow in simple piece of code

Conrad
I can't share the ontology as it is confidential, but I tried it with another one (one without cycles) and it worked fine. This is why I think this is an error not catched.
Reply | Threaded
Open this post in threaded view
|

Re: Stack overflow in simple piece of code

Jiba
Administrator
Could you create a small ontology with similar cycles that allows to reproduce the problem? Or strip down your ontology be removing confidential elements while keeping the problem?

It is almost impossible for me to solve the problem without being able to reproduce it.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Stack overflow in simple piece of code

Mr.Mystery
Sorry to interfere, but I have exactly the same problem. At the moment we are taking a course on ontologies at the university. The problem occurs when trying to infer classes. I attach a link to Github where you can download the ontology. The ontology was created in Protege 5.5 environment with subsequent verification through HermiT.

https://github.com/4e6anenk0/Semantic-Web/blob/master/owl_files/Fashion.owl

Hope this helps.
Reply | Threaded
Open this post in threaded view
|

Re: Stack overflow in simple piece of code

Jiba
Administrator
Hi,

You are welcome to interfere !

I am able to reproduce the problem with your ontology. I've analyzed it, and it is caused by entity "http://www.semanticweb.org/4e6an/ontologies/2020/11/fashion#Alexander_Wang_Co." that is both a class and a named individual. The behaviour of such entities is not clear: some persons consider them as the same entity (this is known as "punning") and some others consider them as two distinct entities (usually, reasoners do that).

Owlready does not allows having entities being both class, individual and/or property.

I'm going to try to add some error message (or ignore the problem with a warning).

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Stack overflow in simple piece of code

Conrad
Thank you! Sorry for not coming back earlier, thanks for resolving this. I will take a look at my ontology and will get the new release as soon as possible!
Reply | Threaded
Open this post in threaded view
|

Re: Stack overflow in simple piece of code

Conrad
Are there any updates on this? It has been a year and I still get stack overflows from a couple of my ontologies.
Reply | Threaded
Open this post in threaded view
|

Re: Stack overflow in simple piece of code

Jiba
Administrator
Hi,

Normally, Owlready should now break the cycle to avoid stack overflow error.

For example, I can list the classes of the Fashion ontology, with the following warnings:

* Owlready2 * Warning: ignoring cyclic type of, involving storid 305

Fashion.Alexander_Wang_Co.

etc.

Are you still getting error? If so, I would be interested in an ontology to reproduce the problem.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Stack overflow in simple piece of code

Conrad
Hi,

This thing just got a lot more mysterious, as it works from the Powershell on my Windows System, but not from the terminal within Visual Studio Code. So I suppose this is not a problem with Owlready.

Thanks for your help anyways! I will investigate further and keep this thread up to date, if I find anything.