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

scapy and no such file or directory: b'liblibc.a' (python 3.9 regression) #45918

Closed
70MM13 opened this issue Feb 3, 2021 · 19 comments · Fixed by #49437
Closed

scapy and no such file or directory: b'liblibc.a' (python 3.9 regression) #45918

70MM13 opened this issue Feb 3, 2021 · 19 comments · Fixed by #49437
Assignees

Comments

@70MM13
Copy link

70MM13 commented Feb 3, 2021

The problem

Just updated to 2021.2.0 and it can't load the dhcp integration

What is version of Home Assistant Core has the issue?

2021.2.0

What was the last working version of Home Assistant Core?

2021.1.5

What type of installation are you running?

Home Assistant Core

Integration causing the issue

dhcp

Link to integration documentation on our website

https://rc.home-assistant.io/integrations/dhcp/

Example YAML snippet

# Put your YAML below this line

Anything in the logs that might be useful for us?

# Put your logs below this line
    from scapy.arch.bpf.core import get_if_raw_addr
  File "/home/tommie/homeassistant/lib/python3.9/site-packages/scapy/arch/bpf/core.py", line 30, in <module>
    LIBC = cdll.LoadLibrary(find_library("libc"))
  File "/usr/lib/python3.9/ctypes/util.py", line 330, in find_library
    _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
  File "/usr/lib/python3.9/ctypes/util.py", line 147, in _findLib_gcc
    if not _is_elf(file):
  File "/usr/lib/python3.9/ctypes/util.py", line 99, in _is_elf
    with open(filename, 'br') as thefile:
FileNotFoundError: [Errno 2] No such file or directory: b'liblibc.a'

Probably related to this: secdev/scapy@46fa40f

@probot-home-assistant
Copy link

dhcp documentation
dhcp source
(message by IssueLinks)

@bdraco
Copy link
Member

bdraco commented Feb 4, 2021

We will bump to scapy 2.4.5 when it comes out.

https://bugs.python.org/issue42580 could solve it sooner with a new version of python.

@bdraco bdraco changed the title scapy and no such file or directory: b'liblibc.a' scapy and no such file or directory: b'liblibc.a' (python 3.9 regression) Feb 4, 2021
@nottledim
Copy link

I get this when I add exclude entity_globs in configuration.yaml

Feb 05 19:07:30 mimas hass[238867]: 2021-02-05 19:07:30 ERROR (MainThread) [homeassistant.setup] Setup failed for dhcp: unknown error
Feb 05 19:07:30 mimas hass[238867]: Traceback (most recent call last):
Feb 05 19:07:30 mimas hass[238867]:   File "/usr/lib/python3.9/site-packages/homeassistant/setup.py", line 166, in _async_setup_component
Feb 05 19:07:30 mimas hass[238867]:     component = integration.get_component()
Feb 05 19:07:30 mimas hass[238867]:   File "/usr/lib/python3.9/site-packages/homeassistant/loader.py", line 467, in get_component
Feb 05 19:07:30 mimas hass[238867]:     cache[self.domain] = importlib.import_module(self.pkg_path)
Feb 05 19:07:30 mimas hass[238867]:   File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
Feb 05 19:07:30 mimas hass[238867]:     return _bootstrap._gcd_import(name[level:], package, level)
Feb 05 19:07:30 mimas hass[238867]:   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
Feb 05 19:07:30 mimas hass[238867]:   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
Feb 05 19:07:30 mimas hass[238867]:   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
Feb 05 19:07:30 mimas hass[238867]:   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
Feb 05 19:07:30 mimas hass[238867]:   File "<frozen importlib._bootstrap_external>", line 790, in exec_module
Feb 05 19:07:30 mimas hass[238867]:   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
Feb 05 19:07:30 mimas hass[238867]:   File "/usr/lib/python3.9/site-packages/homeassistant/components/dhcp/__init__.py", line 10, in <module>
Feb 05 19:07:30 mimas hass[238867]:     from scapy.arch.common import compile_filter
Feb 05 19:07:30 mimas hass[238867]:   File "/var/lib/hass/deps/lib/python3.9/site-packages/scapy/arch/__init__.py", line 27, in <module>
Feb 05 19:07:30 mimas hass[238867]:     from scapy.arch.bpf.core import get_if_raw_addr
Feb 05 19:07:30 mimas hass[238867]:   File "/var/lib/hass/deps/lib/python3.9/site-packages/scapy/arch/bpf/core.py", line 30, in <module>
Feb 05 19:07:30 mimas hass[238867]:     LIBC = cdll.LoadLibrary(find_library("libc"))
Feb 05 19:07:30 mimas hass[238867]:   File "/usr/lib/python3.9/ctypes/util.py", line 330, in find_library
Feb 05 19:07:30 mimas hass[238867]:     _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
Feb 05 19:07:30 mimas hass[238867]:   File "/usr/lib/python3.9/ctypes/util.py", line 147, in _findLib_gcc
Feb 05 19:07:30 mimas hass[238867]:     if not _is_elf(file):
Feb 05 19:07:30 mimas hass[238867]:   File "/usr/lib/python3.9/ctypes/util.py", line 99, in _is_elf
Feb 05 19:07:30 mimas hass[238867]:     with open(filename, 'br') as thefile:
Feb 05 19:07:30 mimas hass[238867]: FileNotFoundError: [Errno 2] No such file or directory: b'liblibc.a'

@OnFreund
Copy link
Contributor

This is also preventing "Restart" (in Server Controls -> Server management) from working.

@bdraco
Copy link
Member

bdraco commented Feb 16, 2021

This is also preventing "Restart" (in Server Controls -> Server management) from working.

@OnFreund

I haven't been able to replicate this.

Can you provide a py-spy dump of the threads when its stuck?

@OnFreund
Copy link
Contributor

It's not stuck - it's just failing to shut down with the following log:

Error executing service: <ServiceCall homeassistant.restart (c:c02ac5bacb1a7ad9bab367beb0e19819)>
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/core.py", line 1471, in catch_exceptions
    await coro_or_task
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/core.py", line 1490, in _execute_service
    await handler.job.target(service_call)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/service.py", line 665, in admin_handler
    await result
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/homeassistant/__init__.py", line 117, in async_handle_core_service
    errors = await conf_util.async_check_ha_config_file(hass)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/config.py", line 877, in async_check_ha_config_file
    res = await check_config.async_check_ha_config_file(hass)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/check_config.py", line 123, in async_check_ha_config_file
    component = integration.get_component()
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/loader.py", line 467, in get_component
    cache[self.domain] = importlib.import_module(self.pkg_path)
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/dhcp/__init__.py", line 13, in <module>
    from scapy.layers.dhcp import DHCP
  File "/srv/homeassistant/lib/python3.9/site-packages/scapy/layers/dhcp.py", line 20, in <module>
    from scapy.ansmachine import AnsweringMachine
  File "/srv/homeassistant/lib/python3.9/site-packages/scapy/ansmachine.py", line 16, in <module>
    from scapy.sendrecv import send, sniff
  File "/srv/homeassistant/lib/python3.9/site-packages/scapy/sendrecv.py", line 35, in <module>
    import scapy.route  # noqa: F401
  File "/srv/homeassistant/lib/python3.9/site-packages/scapy/route.py", line 199, in <module>
    conf.route = Route()
  File "/srv/homeassistant/lib/python3.9/site-packages/scapy/route.py", line 27, in __init__
    self.resync()
  File "/srv/homeassistant/lib/python3.9/site-packages/scapy/route.py", line 33, in resync
    from scapy.arch import read_routes
  File "/srv/homeassistant/lib/python3.9/site-packages/scapy/arch/__init__.py", line 27, in <module>
    from scapy.arch.bpf.core import get_if_raw_addr
  File "/srv/homeassistant/lib/python3.9/site-packages/scapy/arch/bpf/core.py", line 30, in <module>
    LIBC = cdll.LoadLibrary(find_library("libc"))
  File "/usr/lib/python3.9/ctypes/util.py", line 341, in find_library
    _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
  File "/usr/lib/python3.9/ctypes/util.py", line 147, in _findLib_gcc
    if not _is_elf(file):
  File "/usr/lib/python3.9/ctypes/util.py", line 99, in _is_elf
    with open(filename, 'br') as thefile:
FileNotFoundError: [Errno 2] No such file or directory: b'liblibc.a'

@bdraco
Copy link
Member

bdraco commented Feb 16, 2021

Thanks for the trace. That seems like a more general issue with not catching lower level exceptions in the restart. I’ll see what I can work up that should solve it for other cases as well as I don’t think the underlying python bug is going to be fixed soon

@bdraco
Copy link
Member

bdraco commented Feb 16, 2021

Looks like we try to validate the config is valid before restarting. File not found and import errors aren’t configuration problems though. So it’s a bit to broad

@bdraco
Copy link
Member

bdraco commented Feb 16, 2021

I've opened an issue with scapy requesting as new release as monkey patching for https://bugs.python.org/issue42580 is likely very messy

secdev/scapy#3100

@LittleFox94
Copy link

For now I symlinked my libc.a to /usr/local/lib/liblibc.a because I was annoyed by the "invalid config" notification x)

@bdraco
Copy link
Member

bdraco commented Apr 9, 2021

secdev/scapy#3158

@Vaear
Copy link

Vaear commented Apr 13, 2021

The issue seems to persist even in 2.4.5rc1

File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/dhcp/init.py", line 20, in
from scapy.layers.dhcp import DHCP
File "/srv/homeassistant/lib/python3.9/site-packages/scapy/layers/dhcp.py", line 20, in
from scapy.ansmachine import AnsweringMachine
File "/srv/homeassistant/lib/python3.9/site-packages/scapy/ansmachine.py", line 16, in
from scapy.sendrecv import send, sniff
File "/srv/homeassistant/lib/python3.9/site-packages/scapy/sendrecv.py", line 35, in
import scapy.route # noqa: F401
File "/srv/homeassistant/lib/python3.9/site-packages/scapy/route.py", line 199, in
conf.route = Route()
File "/srv/homeassistant/lib/python3.9/site-packages/scapy/route.py", line 27, in init
self.resync()
File "/srv/homeassistant/lib/python3.9/site-packages/scapy/route.py", line 33, in resync
from scapy.arch import read_routes
File "/srv/homeassistant/lib/python3.9/site-packages/scapy/arch/init.py", line 27, in
from scapy.arch.bpf.core import get_if_raw_addr
File "/srv/homeassistant/lib/python3.9/site-packages/scapy/arch/bpf/core.py", line 30, in
LIBC = cdll.LoadLibrary(find_library("libc"))
File "/usr/lib/python3.9/ctypes/util.py", line 341, in find_library
_get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
File "/usr/lib/python3.9/ctypes/util.py", line 147, in _findLib_gcc
if not _is_elf(file):
File "/usr/lib/python3.9/ctypes/util.py", line 99, in _is_elf
with open(filename, 'br') as thefile:
FileNotFoundError: [Errno 2] No such file or directory: b'liblibc.a'

If i am not missing something else here.

@bdraco
Copy link
Member

bdraco commented Apr 13, 2021

File "/srv/homeassistant/lib/python3.9/site-packages/scapy/arch/bpf/core.py", line 30, in
LIBC = cdll.LoadLibrary(find_library("libc"))

https://github.com/secdev/scapy/blob/v2.4.5rc1/scapy/arch/bpf/core.py#L35

It looks like you are still running 2.4.4. If you manually upgraded and didn't modify manifest.json, its pinned to 2.4.4 so it probably downgraded again.

@Vaear
Copy link

Vaear commented Apr 13, 2021

Any chance you know where this manifest.json is located? Is more than one? There is no manifest.json file under the scapy cataloge.

@Vaear
Copy link

Vaear commented Apr 14, 2021

Worked like a charm, thank you for taking the time :) And sorry for bothering you!

@guedou
Copy link

guedou commented Apr 19, 2021

I just released Scapy v2.4.5! Enjoy.

@bdraco
Copy link
Member

bdraco commented Apr 19, 2021

I just released Scapy v2.4.5! Enjoy.

Thank you!

bdraco added a commit to bdraco/home-assistant that referenced this issue Apr 19, 2021
@bdraco
Copy link
Member

bdraco commented Apr 20, 2021

Unfortunately we have hit a small snag pylint-dev/pylint#4383

bdraco added a commit to bdraco/home-assistant that referenced this issue Apr 25, 2021
@github-actions github-actions bot locked and limited conversation to collaborators May 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants