Skip to content

Commit ab2ad7e

Browse files
Apply Victor's suggestions
Co-authored-by: Victor Stinner <victor.stinner@gmail.com>
1 parent 5c0f7ae commit ab2ad7e

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

‎Include/pyport.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ extern "C" {
558558
# define _Py_MEMORY_SANITIZER
559559
# define _Py_NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory))
560560
# define _Py_MSAN_UNPOISON(PTR, SIZE) (__msan_unpoison(PTR, SIZE))
561-
# define _Py_MSAN_UNPOISON_STRING(PTR) (__msan_unpoison_string(PTR))
561+
# define _Py_MSAN_UNPOISON_STRING(STR) (__msan_unpoison_string(STR))
562562
# endif
563563
# endif
564564
# if __has_feature(address_sanitizer)
@@ -601,7 +601,7 @@ extern "C" {
601601
# define _Py_MSAN_UNPOISON(PTR, SIZE)
602602
#endif
603603
#ifndef _Py_MSAN_UNPOISON_STRING
604-
# define _Py_MSAN_UNPOISON_STRING(PTR)
604+
# define _Py_MSAN_UNPOISON_STRING(STR)
605605
#endif
606606

607607
/* AIX has __bool__ redefined in it's system header file. */

‎Lib/test/test_faulthandler.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434

3535

3636
def skip_if_sanitizer_signal(signame):
37-
return support.skip_if_sanitizer(f"TSAN/UBSan itercepts {signame}",
38-
thread=True, ub=True)
37+
return support.skip_if_sanitizer(f"TSan/UBSan/MSan intercepts {signame}",
38+
thread=True, ub=True, memory=True)
3939

4040

4141
def expected_traceback(lineno1, lineno2, header, min_count=1):

‎Modules/socketmodule.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,6 @@ set_error(void)
763763
static PyObject *
764764
decode_error_message(const char *str)
765765
{
766-
_Py_MSAN_UNPOISON_STRING(str);
767766
return PyUnicode_DecodeLocale(str, "surrogateescape");
768767
}
769768
#endif
@@ -775,7 +774,9 @@ set_herror(socket_state *state, int h_error)
775774
PyObject *v;
776775

777776
#ifdef HAVE_HSTRERROR
778-
v = Py_BuildValue("(iN)", h_error, decode_error_message(hstrerror(h_error)));
777+
const char *errmsg = hstrerror(h_error);
778+
_Py_MSAN_UNPOISON_STRING(errmsg);
779+
v = Py_BuildValue("(iN)", h_error, decode_error_message(errmsg));
779780
#else
780781
v = Py_BuildValue("(is)", h_error, "host not found");
781782
#endif
@@ -802,7 +803,9 @@ set_gaierror(socket_state *state, int error)
802803
#endif
803804

804805
#ifdef HAVE_GAI_STRERROR
805-
v = Py_BuildValue("(iN)", error, decode_error_message(gai_strerror(error)));
806+
const char *errmsg = gai_strerror(error);
807+
_Py_MSAN_UNPOISON_STRING(errmsg);
808+
v = Py_BuildValue("(iN)", error, decode_error_message(errmsg));
806809
#else
807810
v = Py_BuildValue("(is)", error, "getaddrinfo failed");
808811
#endif

0 commit comments

Comments
 (0)