From f081d1db83bf0e85f774978878f538fea7c0a313 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith [Google LLC]" Date: Sun, 30 Dec 2018 18:49:50 -0800 Subject: [PATCH 1/4] skip test_constructor under msan. --- Lib/test/test_io.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index c3644875103da0..737eadde5c0f40 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -28,6 +28,7 @@ import random import signal import sys +import sysconfig import threading import time import unittest @@ -59,6 +60,13 @@ def byteslike(*pos, **kw): class EmptyStruct(ctypes.Structure): pass +_cflags = sysconfig.get_config_var('CFLAGS') or '' +_config_args = sysconfig.get_config_var('CONFIG_ARGS') or '' +MEMORY_SANITIZER = ( + '-fsanitizer=memory' in _cflags or + '--with-memory-sanitizer' in _config_args +) + def _default_chunk_size(): """Get the default TextIOWrapper chunk size""" with open(__file__, "r", encoding="latin-1") as f: @@ -1496,6 +1504,8 @@ def test_read_on_closed(self): class CBufferedReaderTest(BufferedReaderTest, SizeofTest): tp = io.BufferedReader + @unittest.skipIf(MEMORY_SANITIZER, "MSan defaults to crashing " + "instead of returning NULL for malloc failure.") def test_constructor(self): BufferedReaderTest.test_constructor(self) # The allocation can succeed on 32-bit builds, e.g. with more From e0fa1081b07be76d99dd39b686097251891afb08 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith [Google LLC]" Date: Sun, 30 Dec 2018 18:53:46 -0800 Subject: [PATCH 2/4] fix the others as well. --- Lib/test/test_io.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 737eadde5c0f40..e3deab86e0910d 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -1850,6 +1850,8 @@ def test_slow_close_from_thread(self): class CBufferedWriterTest(BufferedWriterTest, SizeofTest): tp = io.BufferedWriter + @unittest.skipIf(MEMORY_SANITIZER, "MSan defaults to crashing " + "instead of returning NULL for malloc failure.") def test_constructor(self): BufferedWriterTest.test_constructor(self) # The allocation can succeed on 32-bit builds, e.g. with more @@ -2324,6 +2326,8 @@ def test_interleaved_readline_write(self): class CBufferedRandomTest(BufferedRandomTest, SizeofTest): tp = io.BufferedRandom + @unittest.skipIf(MEMORY_SANITIZER, "MSan defaults to crashing " + "instead of returning NULL for malloc failure.") def test_constructor(self): BufferedRandomTest.test_constructor(self) # The allocation can succeed on 32-bit builds, e.g. with more From 131f79662e27a5e63776ba224eb34d9d86d2fb1f Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith [Google LLC]" Date: Sun, 30 Dec 2018 18:55:28 -0800 Subject: [PATCH 3/4] reuse existing related news entry. --- .../Core and Builtins/2018-12-30-15-36-23.bpo-35214.GWDQcv.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-12-30-15-36-23.bpo-35214.GWDQcv.rst b/Misc/NEWS.d/next/Core and Builtins/2018-12-30-15-36-23.bpo-35214.GWDQcv.rst index d2e5457842b748..62dee0e37008a7 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2018-12-30-15-36-23.bpo-35214.GWDQcv.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2018-12-30-15-36-23.bpo-35214.GWDQcv.rst @@ -1,2 +1,2 @@ clang Memory Sanitizer build instrumentation was added to work around false -positives from socket, time, and test_faulthandler. +positives from socket, time, test_io, and test_faulthandler. From a58f9f06007fe600825d2e7a155acedf7da0ce3f Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Sun, 30 Dec 2018 20:01:43 -0800 Subject: [PATCH 4/4] typo fix --- Lib/test/test_io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index e3deab86e0910d..d245c5d846ad76 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -63,7 +63,7 @@ class EmptyStruct(ctypes.Structure): _cflags = sysconfig.get_config_var('CFLAGS') or '' _config_args = sysconfig.get_config_var('CONFIG_ARGS') or '' MEMORY_SANITIZER = ( - '-fsanitizer=memory' in _cflags or + '-fsanitize=memory' in _cflags or '--with-memory-sanitizer' in _config_args )