Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault when calling kb.get_vector #9137

Closed
Joozty opened this issue Sep 4, 2021 · 4 comments · Fixed by #9463
Closed

Segmentation fault when calling kb.get_vector #9137

Joozty opened this issue Sep 4, 2021 · 4 comments · Fixed by #9463
Labels
bug Bugs and behaviour differing from documentation feat / nel Feature: Named Entity linking plat / m1 Apple M1 architecture support

Comments

@Joozty
Copy link
Contributor

Joozty commented Sep 4, 2021

How to reproduce the behaviour

When I run this example I get a segmentation fault. I am not sure how to get a stacktrace. I tried to set this env variable PYTHONFAULTHANDLER=1 but I get only this:

Fatal Python error: Segmentation fault

Current thread 0x000000010099fd40 (most recent call first):
  File "/Users/joozty/Documents/kb_test.py", line 24 in <module>

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

I should note that I am using a new MacBook with an M1 chip so it can be something platform specific. Also, it happens only when I serialize KB which was generated with set_entities. When I add entity one by one it works just fine.

Code to reproduce:

from spacy.kb import KnowledgeBase
import spacy

# works fine
# nlp = spacy.load("en_core_web_md")
# kb = KnowledgeBase(vocab=nlp.vocab, entity_vector_length=300)
# kb.add_entity("1", 1, nlp("test").vector)
# kb.to_disk("test")
#
# kb1 = KnowledgeBase(vocab=nlp.vocab, entity_vector_length=300)
# kb1.from_disk("test")
# kb1.get_vector("1")



# fails with Segmentation fault
nlp = spacy.load("en_core_web_md")
kb = KnowledgeBase(vocab=nlp.vocab, entity_vector_length=300)
kb.set_entities(["1"], [1], [nlp("test").vector])
kb.to_disk("test")

kb1 = KnowledgeBase(vocab=nlp.vocab, entity_vector_length=300)
kb1.from_disk("test")
kb1.get_vector("1")

Your Environment

Info about spaCy

  • spaCy version: 3.1.2
  • Platform: macOS-11.5.2-arm64-arm-64bit
  • Python version: 3.9.6
  • Pipelines: xx_ent_wiki_sm (3.1.0), en_core_web_sm (3.1.0), en_core_web_md (3.1.0)
@polm polm added feat / nel Feature: Named Entity linking bug Bugs and behaviour differing from documentation labels Sep 4, 2021
@adrianeboyd
Copy link
Contributor

Thanks for the report! I can reproduce this error and it doesn't look platform-specific. We will look into it!

@WMRamadan
Copy link

WMRamadan commented Sep 23, 2021

I can confirm this problem can be reproduced on the following:
OS: Ubuntu Linux 21.04
Kernel: 5.11.0-34-generic
Python: 3.9.5
Pip: 20.3.4
spaCy: 3.1.3

A trace revealed the problem is related to the following method https://github.com/explosion/spaCy/blob/master/spacy/kb.pyx#L307

I believe specifically to https://github.com/explosion/spaCy/blob/master/spacy/kb.pyx#L315
where self._vectors_table[] appears to be the problem.

Which is initialized here https://github.com/explosion/spaCy/blob/master/spacy/kb.pyx#L99

Where float_matrix is being declared from spacy/kb.pyd here https://github.com/explosion/spaCy/blob/master/spacy/kb.pxd#L16

@svlandeg svlandeg mentioned this issue Oct 14, 2021
3 tasks
@svlandeg
Copy link
Member

Hi all, thanks for your patience! An explanation and solution for this bug is provided in #9463.

@polm polm added the plat / m1 Apple M1 architecture support label Nov 4, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bugs and behaviour differing from documentation feat / nel Feature: Named Entity linking plat / m1 Apple M1 architecture support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants