Unverified Kaydet (Commit) e5796c42 authored tarafından Gregory P. Smith's avatar Gregory P. Smith Kaydeden (comit) GitHub

bpo-35214: Skip test_io tests that'd cause a huge malloc under msan (#11385)

* skip test_constructor under msan.

* fix the others as well.

* reuse existing related news entry.

* typo fix
üst d6f45b23
...@@ -28,6 +28,7 @@ import pickle ...@@ -28,6 +28,7 @@ import pickle
import random import random
import signal import signal
import sys import sys
import sysconfig
import threading import threading
import time import time
import unittest import unittest
...@@ -59,6 +60,13 @@ else: ...@@ -59,6 +60,13 @@ else:
class EmptyStruct(ctypes.Structure): class EmptyStruct(ctypes.Structure):
pass pass
_cflags = sysconfig.get_config_var('CFLAGS') or ''
_config_args = sysconfig.get_config_var('CONFIG_ARGS') or ''
MEMORY_SANITIZER = (
'-fsanitize=memory' in _cflags or
'--with-memory-sanitizer' in _config_args
)
def _default_chunk_size(): def _default_chunk_size():
"""Get the default TextIOWrapper chunk size""" """Get the default TextIOWrapper chunk size"""
with open(__file__, "r", encoding="latin-1") as f: with open(__file__, "r", encoding="latin-1") as f:
...@@ -1496,6 +1504,8 @@ class BufferedReaderTest(unittest.TestCase, CommonBufferedTests): ...@@ -1496,6 +1504,8 @@ class BufferedReaderTest(unittest.TestCase, CommonBufferedTests):
class CBufferedReaderTest(BufferedReaderTest, SizeofTest): class CBufferedReaderTest(BufferedReaderTest, SizeofTest):
tp = io.BufferedReader tp = io.BufferedReader
@unittest.skipIf(MEMORY_SANITIZER, "MSan defaults to crashing "
"instead of returning NULL for malloc failure.")
def test_constructor(self): def test_constructor(self):
BufferedReaderTest.test_constructor(self) BufferedReaderTest.test_constructor(self)
# The allocation can succeed on 32-bit builds, e.g. with more # The allocation can succeed on 32-bit builds, e.g. with more
...@@ -1840,6 +1850,8 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests): ...@@ -1840,6 +1850,8 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests):
class CBufferedWriterTest(BufferedWriterTest, SizeofTest): class CBufferedWriterTest(BufferedWriterTest, SizeofTest):
tp = io.BufferedWriter tp = io.BufferedWriter
@unittest.skipIf(MEMORY_SANITIZER, "MSan defaults to crashing "
"instead of returning NULL for malloc failure.")
def test_constructor(self): def test_constructor(self):
BufferedWriterTest.test_constructor(self) BufferedWriterTest.test_constructor(self)
# The allocation can succeed on 32-bit builds, e.g. with more # The allocation can succeed on 32-bit builds, e.g. with more
...@@ -2314,6 +2326,8 @@ class BufferedRandomTest(BufferedReaderTest, BufferedWriterTest): ...@@ -2314,6 +2326,8 @@ class BufferedRandomTest(BufferedReaderTest, BufferedWriterTest):
class CBufferedRandomTest(BufferedRandomTest, SizeofTest): class CBufferedRandomTest(BufferedRandomTest, SizeofTest):
tp = io.BufferedRandom tp = io.BufferedRandom
@unittest.skipIf(MEMORY_SANITIZER, "MSan defaults to crashing "
"instead of returning NULL for malloc failure.")
def test_constructor(self): def test_constructor(self):
BufferedRandomTest.test_constructor(self) BufferedRandomTest.test_constructor(self)
# The allocation can succeed on 32-bit builds, e.g. with more # The allocation can succeed on 32-bit builds, e.g. with more
......
clang Memory Sanitizer build instrumentation was added to work around false 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.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment