Skip to content

gh-158893: Add internal _Py_strerror() function - #158982

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:strerror2
Oct 7, 2026
Merged

vstinner merged 1 commit into
python:mainfrom
vstinner:strerror2

Conversation

@vstinner

@vstinner vstinner commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Add a new internal _Py_strerror() function to Python/fileutils.c. It uses strerror_r() if available, or use strerror() otherwise.

Replace all strerror(code) calls with _Py_strerror(code).

Add a new internal _Py_strerror() function to Python/fileutils.c. It
uses strerror_r() if available, or use strerror() otherwise.

Replace all strerror(code) calls with _Py_strerror(code).
@vstinner

vstinner commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

On FreeBSD 14, I can reproduce the issue by running test_concurrent_initialization_subinterpreter() of test_datetime in a loop. For example, it crashed at the 4th run:

vstinner@freebsd14$ ./python -m test test_datetime -v -m test_concurrent_initialization_subinterpreter -F
(...)
0:00:05 load avg: 1.85 mem: 37.5 MiB [  4] test_datetime
test_concurrent_initialization_subinterpreter (test.datetimetester.ExtensionModuleTests_Pure.test_concurrent_initialization_subinterpreter) ... skipped 'Not relevant in pure Python'
test_concurrent_initialization_subinterpreter (test.datetimetester.ExtensionModuleTests_Fast.test_concurrent_initialization_subinterpreter) ... FAIL

======================================================================
FAIL: test_concurrent_initialization_subinterpreter (test.datetimetester.ExtensionModuleTests_Fast.test_concurrent_initialization_subinterpreter)
(...)
AssertionError: Process return code is -6 (SIGABRT)
command line: ['/home/vstinner/python/main/python', '-X', 'faulthandler', '-I', '-c', "if True:\n        from concurrent.futures import InterpreterPoolExecutor\n\n        def func():\n            import _datetime\n            print('a', end='')\n\n        with InterpreterPoolExecutor() as executor:\n            for _ in range(8):\n                executor.submit(func)\n        "]

(...)

stderr:
---
Assertion failed: (strlen(arg) == arglen), function _Py_DecodeLocale, file Python/fileutils.c, line 733.
Fatal Python error: Aborted

Current thread 0x000014c00b026010 [InterpreterPoolExec] (most recent call first):
  File "<frozen importlib._bootstrap_external>", line 155 in _path_stat
  File "<frozen importlib._bootstrap_external>", line 161 in _path_is_mode_type
  File "<frozen importlib._bootstrap_external>", line 169 in _path_isfile
  File "<frozen importlib._bootstrap_external>", line 1386 in find_spec
  File "<frozen importlib._bootstrap_external>", line 1251 in _get_spec
  File "<frozen importlib._bootstrap_external>", line 1277 in find_spec
  File "<frozen importlib._bootstrap>", line 1216 in _find_spec
  File "<frozen importlib._bootstrap>", line 1292 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1344 in _find_and_load
  File "/home/vstinner/python/main/Lib/concurrent/futures/_base.py", line 7 in <module>
  (...)

With the fix, the test no longer crash. I ran the test 188 times in 6 minutes.

@vstinner

vstinner commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

Oh, CIFuzz jobs failed with networking issue. Example:

#6 416.3 E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/f/file/libmagic-mgc_5.38-4_amd64.deb Connection failed [IP: 91.189.91.81 80]

@vstinner
vstinner enabled auto-merge (squash) October 7, 2026 20:23
@vstinner
vstinner merged commit 15dd735 into python:main Oct 7, 2026
52 of 55 checks passed
@vstinner
vstinner deleted the strerror2 branch October 7, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant