Skip to content

ctypes.util.find_library raises FileNotFoundError for libsecp256k1 #93094

@relativisticelectron

Description

@relativisticelectron

Bug report

The following script

import ctypes
from ctypes import  util

print(f'ctypes version {ctypes.__version__}')


print('Test foofoofoo')
print(f"returns: {util.find_library('foofoofoo')}\n")

print('Test secp256k1')
print(f"returns: {util.find_library('secp256k1')}\n")

print('Test libsecp256k1')
print(f"returns: {util.find_library('libsecp256k1')}\n")

gives the output:

ctypes version 1.1.0
Test foofoofoo
returns: None

Test secp256k1
returns: libsecp256k1.so.0

Test libsecp256k1
Traceback (most recent call last):
  File "/home/<user>/programs/testctypes.py", line 14, in <module>
    print(f"returns: {util.find_library('libsecp256k1')}\n")
  File "/home/<user>/programs/anaconda3/envs/python310/lib/python3.10/ctypes/util.py", line 351, in find_library
    _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
  File "/home/<user>/programs/anaconda3/envs/python310/lib/python3.10/ctypes/util.py", line 148, in _findLib_gcc
    if not _is_elf(file):
  File "/home/<user>/programs/anaconda3/envs/python310/lib/python3.10/ctypes/util.py", line 100, in _is_elf
    with open(filename, 'br') as thefile:
FileNotFoundError: [Errno 2] No such file or directory: b'liblibsecp256k1.a'

find_library should not fail, but return None if nothing was found. In Ubuntu 20.04 this script runs without any exception.

Your environment

  • ctypes version 1.1.0
  • Operating system and architecture: Kubuntu 22.04 LTS x86_64, linux 5.15.0-27-generic
  • Bug can be reproduced in python versions: python 3.10 (via anaconda and via ubuntu deb repositories), python 3.8 (via anaconda)
  • The installed libsecp256k1 packages are
    image

image contains the files

/.
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libsecp256k1.so.0
/usr/lib/x86_64-linux-gnu/libsecp256k1.so.0.0.0
/usr/share
/usr/share/doc
/usr/share/doc/libsecp256k1-0
/usr/share/doc/libsecp256k1-0/changelog.Debian.gz
/usr/share/doc/libsecp256k1-0/copyright

And image contains the files

/.
/usr
/usr/include
/usr/include/secp256k1.h
/usr/include/secp256k1_ecdh.h
/usr/include/secp256k1_extrakeys.h
/usr/include/secp256k1_preallocated.h
/usr/include/secp256k1_recovery.h
/usr/include/secp256k1_schnorrsig.h
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libsecp256k1.a
/usr/lib/x86_64-linux-gnu/libsecp256k1.so
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/libsecp256k1.pc
/usr/share
/usr/share/doc
/usr/share/doc/libsecp256k1-dev
/usr/share/doc/libsecp256k1-dev/changelog.Debian.gz
/usr/share/doc/libsecp256k1-dev/copyright

And in /usr/lib/x86_64-linux-gnu/ are the following relevant files containing secp256k1:
image

This bug was noticed in cryptoadvance/specter-desktop#1710

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy