pyauth / pyauth/python-pkcs11

segfaulting only on github action

Open
#171 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
170
Forks
79
PR merge metrics
No merged PRs in 30d

Description

I am having a corner case where while generating RSA keys (using softhsm2) on Bookwork python images on github action (3rd key generation in the tests) it is segfaulting. Happening across various Python versions. If I run only the affected tests, then no issues. The tests are running happily in the local system. Any tips?

Fatal Python error: Segmentation fault

Thread 0x00007f57077646c0 (most recent call first):
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 89 in _worker
  File "/usr/local/lib/python3.12/threading.py", line 1010 in run
  File "/usr/local/lib/python3.12/threading.py", line 1073 in _bootstrap_inner
  File "/usr/local/lib/python3.12/threading.py", line 1030 in _bootstrap

Current thread 0x00007f570a3dcb80 (most recent call first):
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/pkcs11/types.py", line 509 in generate_keypair
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/src/python_x509_pkcs11/pkcs11_handle.py", line 526 in create_keypair
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88 in _run
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1985 in _run_once
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639 in run_forever
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672 in run_until_complete
  File "/usr/local/lib/python3.12/asyncio/runners.py", line 118 in run
  File "/usr/local/lib/python3.12/asyncio/runners.py", line 194 in run
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/tests/test_privatekeys.py", line 42 in test_rsa_private_key
  File "/usr/local/lib/python3.12/unittest/case.py", line 589 in _callTestMethod
  File "/usr/local/lib/python3.12/unittest/case.py", line 634 in run
  File "/usr/local/lib/python3.12/unittest/case.py", line 690 in __call__
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/_pytest/unittest.py", line 338 in runtest
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 174 in pytest_runtest_call
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 102 in _multicall
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 119 in _hookexec
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 501 in __call__
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 267 in <lambda>
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 346 in from_call
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 266 in call_runtest_hook
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 227 in call_and_report
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 134 in runtestprotocol
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/_pytest/runner.py", line 115 in pytest_runtest_protocol
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 102 in _multicall
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 119 in _hookexec
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 501 in __call__
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/_pytest/main.py", line 352 in pytest_runtestloop
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 102 in _multicall
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 119 in _hookexec
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 501 in __call__
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/_pytest/main.py", line 327 in _main
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/_pytest/main.py", line 273 in wrap_session
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/_pytest/main.py", line 320 in pytest_cmdline_main
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/pluggy/_callers.py", line 102 in _multicall
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/pluggy/_manager.py", line 119 in _hookexec
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/pluggy/_hooks.py", line 501 in __call__
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 175 in main
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/lib/python3.12/site-packages/_pytest/config/__init__.py", line 198 in console_main
  File "/__w/python_x509_pkcs11/python_x509_pkcs11/.venv/bin/pytest", line 8 in <module>

Extension modules: multidict._multidict, yarl._quoting_c, aiohttp._helpers, aiohttp._http_writer, aiohttp._http_parser, aiohttp._websocket, frozenlist._frozenlist, _cffi_backend, pkcs11._pkcs11 (total: 9)
Segmentation fault (core dumped)
tests/test_privatekeys.py::TestPrivateKeys::test_rsa_private_key 

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the affected test, tests/test_privatekeys.py::TestPrivateKeys::test_rsa_private_key, in the GitHub Actions Bookworm environment and compare it with an isolated run. Trace the RSA key-generation path through src/python_x509_pkcs11/pkcs11_handle.py:create_keypair and the pkcs11.types generate_keypair call. Done means the full test suite no longer segfaults in that environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.