Skip to content

Commit 033ce38

Browse files
strerror is now thread safe (#8648)
Before glibc 2.32, `strerror`() is not MT-Safe. (from man strerror on Ubuntu 26.04). glibc 2.32 was released on 2020-08-05 and glibc 2.43 on 2026-01-24 (from https://sourceware.org/glibc/wiki/Glibc%20Timeline) This patch stops the `threadsafety.py` addon from warning about `strerror()`. `strerror` was used in `test/cli/other_test.py` to test `threadsafety.py` so we also patch that to use a different thread-unsafe function.
1 parent 39574c6 commit 033ce38

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

‎addons/threadsafety.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@
9191
'race:stdin',
9292
'race:stdout',
9393
'race:streams',
94-
'race:strerror',
9594
'race:strsignal',
9695
'race:strtok',
9796
'race:tmbuf',
@@ -261,7 +260,6 @@
261260
'siginterrupt',
262261
'sleep',
263262
'srand48',
264-
'strerror',
265263
'strsignal',
266264
'strtok',
267265
'tmpnam',

‎test/cli/other_test.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,9 @@ def test_addon_threadsafety(tmpdir):
482482
test_file = os.path.join(tmpdir, 'test.cpp')
483483
with open(test_file, 'wt') as f:
484484
f.write("""
485-
extern const char* f()
485+
extern void f()
486486
{
487-
return strerror(1);
487+
elf_fill(1);
488488
}
489489
""")
490490

@@ -496,7 +496,7 @@ def test_addon_threadsafety(tmpdir):
496496
assert lines == [
497497
'Checking {} ...'.format(test_file)
498498
]
499-
assert stderr == '{}:4:12: warning: strerror is MT-unsafe [threadsafety-unsafe-call]\n'.format(test_file)
499+
assert stderr == '{}:4:5: warning: elf_fill is MT-unsafe [threadsafety-unsafe-call]\n'.format(test_file)
500500

501501

502502
def test_addon_naming(tmpdir):

0 commit comments

Comments
 (0)