]> granicus.if.org Git - python/commitdiff
Issue #9670: Increase the default stack size for secondary threads on
authorNed Deily <nad@acm.org>
Sat, 28 May 2011 07:45:52 +0000 (00:45 -0700)
committerNed Deily <nad@acm.org>
Sat, 28 May 2011 07:45:52 +0000 (00:45 -0700)
Mac OS X and FreeBSD to reduce the chances of a crash instead of a
"maximum recursion depth" RuntimeError exception.
(patch by Ronald Oussoren)

1  2 
Lib/test/test_threading.py
Misc/NEWS
Python/thread_pthread.h

index 2dc77733f758d0ccf116603bde51caf8f5652738,416d95f68d7b20bd57b9ede46ab341ae6799ace7..c22d965495e6e1e382654e759157c015693180e9
@@@ -699,10 -692,37 +700,41 @@@ class ThreadingExceptionTests(BaseTestC
          thread.start()
          self.assertRaises(RuntimeError, setattr, thread, "daemon", True)
  
 +    def test_releasing_unacquired_lock(self):
 +        lock = threading.Lock()
 +        self.assertRaises(RuntimeError, lock.release)
 +
+     @unittest.skipUnless(sys.platform == 'darwin', 'test macosx problem')
+     def test_recursion_limit(self):
+         # Issue 9670
+         # test that excessive recursion within a non-main thread causes
+         # an exception rather than crashing the interpreter on platforms
+         # like Mac OS X or FreeBSD which have small default stack sizes
+         # for threads
+         script = """if True:
+             import threading
+             def recurse():
+                 return recurse()
+             def outer():
+                 try:
+                     recurse()
+                 except RuntimeError:
+                     pass
+             w = threading.Thread(target=outer)
+             w.start()
+             w.join()
+             print('end of main thread')
+             """
+         expected_output = "end of main thread\n"
+         p = subprocess.Popen([sys.executable, "-c", script],
+                              stdout=subprocess.PIPE)
+         stdout, stderr = p.communicate()
+         data = stdout.decode().replace('\r', '')
+         self.assertEqual(p.returncode, 0, "Unexpected error")
+         self.assertEqual(data, expected_output)
  
  class LockTests(lock_tests.LockTests):
      locktype = staticmethod(threading.Lock)
diff --cc Misc/NEWS
index 9c00590e0608eef9ddf26be278cdec73d6603c94,e5267aa2e889bee243fcb7efe9df78754deda80c..3238406e67d12f714a7e5fd6603669bed099b525
+++ b/Misc/NEWS
@@@ -10,14 -10,25 +10,19 @@@ What's New in Python 3.3 Alpha 1
  Core and Builtins
  -----------------
  
 -Library
 --------
 -
 -- Issue #12175: RawIOBase.readall() now returns None if read() returns None.
 -
 -- Issue #12175: FileIO.readall() now raises a ValueError instead of an IOError
 -  if the file is closed.
+ - Issue #9670: Increase the default stack size for secondary threads on
+   Mac OS X and FreeBSD to reduce the chances of a crash instead of a
+   "maximum recursion depth" RuntimeError exception.
+   (patch by Ronald Oussoren)
 +- Issue #12106: The use of the multiple-with shorthand syntax is now reflected
 +  in the AST.
  
 -- Issue #12070: Fix the Makefile parser of the sysconfig module to handle
 -  correctly references to "bogus variable" (e.g. "prefix=$/opt/python").
 +- Issue #12190: Try to use the same filename object when compiling unmarshalling
 +  a code objects in the same file.
  
 -- Issue #12100: Don't reset incremental encoders of CJK codecs at each call to
 -  their encode() method anymore, but continue to call the reset() method if the
 -  final argument is True.
 +- Issue #12166: Move implementations of dir() specialized for various types into
 +  the __dir__() methods of those types.
  
  - Issue #5715: In socketserver, close the server socket in the child process.
  
Simple merge