summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-05-29 17:57:29 +0200
committerÉric Araujo <merwok@netwok.org>2011-05-29 17:57:29 +0200
commitc704b9b76ec3db1f76814fc6dd5d4f6df586874d (patch)
tree3a1586e0ac3b65473dd367722282363e134798f9
parent2df46a8b7dff7a2cc5257083e18ec39fc6cab94f (diff)
parente08f2eaac95d68eaeaf347239d07d9b2c3ddf1a9 (diff)
downloadcpython-c704b9b76ec3db1f76814fc6dd5d4f6df586874d.tar.gz
Branch merge
-rw-r--r--Lib/test/test_threading.py31
-rw-r--r--Mac/Makefile.in13
-rw-r--r--Makefile.pre.in2
-rw-r--r--Misc/NEWS11
-rw-r--r--Python/thread_pthread.h12
5 files changed, 68 insertions, 1 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index 0062634f7e..946c1d2b7c 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -689,6 +689,37 @@ class SemaphoreTests(lock_tests.SemaphoreTests):
class BoundedSemaphoreTests(lock_tests.BoundedSemaphoreTests):
semtype = staticmethod(threading.BoundedSemaphore)
+ @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)
def test_main():
test.test_support.run_unittest(LockTests, RLockTests, EventTests,
diff --git a/Mac/Makefile.in b/Mac/Makefile.in
index 5ab0ae5f09..0e4e0706e5 100644
--- a/Mac/Makefile.in
+++ b/Mac/Makefile.in
@@ -77,6 +77,13 @@ installunixtools:
do \
ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
done
+ifneq ($(LIPO_32BIT_FLAGS),)
+ for fn in python-32 pythonw-32 \
+ python$(VERSION)-32 pythonw$(VERSION)-32 ;\
+ do \
+ ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
+ done
+endif
#
@@ -91,6 +98,12 @@ altinstallunixtools:
do \
ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
done
+ifneq ($(LIPO_32BIT_FLAGS),)
+ for fn in python$(VERSION)-32 pythonw$(VERSION)-32 ;\
+ do \
+ ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\
+ done
+endif
ln -fs "$(prefix)/bin/2to3-$(VERSION)" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/2to3-$(VERSION)" ;\
# By default most tools are installed without a version in their basename, to
diff --git a/Makefile.pre.in b/Makefile.pre.in
index fbd54c7ba7..ed0d116489 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -854,7 +854,7 @@ PLATMACDIRS= plat-mac plat-mac/Carbon plat-mac/lib-scriptpackages \
PLATMACPATH=:plat-mac:plat-mac/lib-scriptpackages
LIBSUBDIRS= lib-tk lib-tk/test lib-tk/test/test_tkinter \
lib-tk/test/test_ttk site-packages test test/data \
- test/cjkencodings test/decimaltestdata test/xmltestdata \
+ test/cjkencodings test/decimaltestdata test/xmltestdata test/subprocessdata \
test/tracedmodules \
encodings compiler hotshot \
email email/mime email/test email/test/data \
diff --git a/Misc/NEWS b/Misc/NEWS
index ae2b5fa53a..4540d5f242 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -9,6 +9,11 @@ What's New in Python 2.7.2?
Core and Builtins
-----------------
+- 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)
+
- Correct lookup of __dir__ on objects. Among other things, this causes errors
besides AttributeError found on lookup to be propagated.
@@ -432,6 +437,10 @@ Extension Modules
Build
-----
+- Issue #11217: For 64-bit/32-bit Mac OS X universal framework builds,
+ ensure "make install" creates symlinks in --prefix bin for the "-32"
+ files in the framework bin directory like the installer does.
+
- Issue #11411: Fix 'make DESTDIR=' with a relative destination.
- Issue #10709: Add updated AIX notes in Misc/README.AIX.
@@ -479,6 +488,8 @@ IDLE
Tests
-----
+- Issue #12205: Fix test_subprocess failure due to uninstalled test data.
+
- Issue #5723: Improve json tests to be executed with and without accelerations.
- Issue #11910: Fix test_heapq to skip the C tests when _heapq is missing.
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index ef49a30849..44e2552a8a 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -18,6 +18,18 @@
#ifndef THREAD_STACK_SIZE
#define THREAD_STACK_SIZE 0 /* use default stack size */
#endif
+
+#if (defined(__APPLE__) || defined(__FreeBSD__)) && defined(THREAD_STACK_SIZE) && THREAD_STACK_SIZE == 0
+ /* The default stack size for new threads on OSX is small enough that
+ * we'll get hard crashes instead of 'maximum recursion depth exceeded'
+ * exceptions.
+ *
+ * The default stack size below is the minimal stack size where a
+ * simple recursive function doesn't cause a hard crash.
+ */
+#undef THREAD_STACK_SIZE
+#define THREAD_STACK_SIZE 0x400000
+#endif
/* for safety, ensure a viable minimum stacksize */
#define THREAD_STACK_MIN 0x8000 /* 32kB */
#else /* !_POSIX_THREAD_ATTR_STACKSIZE */