diff options
author | Hongxu Jia <hongxu.jia@windriver.com> | 2017-08-04 04:18:45 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-08-13 09:27:37 +0100 |
commit | 365b18dbef1e28db4688129cc3ad3db111b03285 (patch) | |
tree | 7596bb1b4621ed55ef69c8c49b49aebbecae9002 /meta/recipes-devtools/python | |
parent | 03eb3b4670f5c99e5039ff2ae7e681cdea9b6d44 (diff) | |
download | poky-365b18dbef1e28db4688129cc3ad3db111b03285.tar.gz |
python2/python3: fix multiprocessing.BoundedSemaphore not work on qemux86/qemuarm
In upstream, the following commit:
https://github.com/python/cpython/commit/e711cafab13efc9c1fe6c5cd75826401445eb585
...
commit e711cafab13efc9c1fe6c5cd75826401445eb585
Author: Benjamin Peterson <benjamin@python.org>
Date: Wed Jun 11 16:44:04 2008 +0000
Merged revisions 64104,64117 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
...
(see diff in setup.py)
It assigned libraries for multiprocessing module according
the host_platform, but not pass it to Extension.
In glibc, the following commit caused two definition of
sem_getvalue are different.
https://sourceware.org/git/?p=glibc.git;a=commit;h=042e1521c794a945edc43b5bfa7e69ad70420524
(see diff in nptl/sem_getvalue.c for detail)
`__new_sem_getvalue' is the latest sem_getvalue@@GLIBC_2.1
and `__old_sem_getvalue' is to compat the old version
sem_getvalue@GLIBC_2.0.
If not explicitly link to library pthread (-lpthread), it will
load glibc's sem_getvalue randomly at runtime.
Such as build python on linux x86_64 host and run the python
on linux x86_32 target. If not link library pthread, it caused
multiprocessing bounded semaphore could not work correctly.
...
>>> import multiprocessing
>>> pool_sema = multiprocessing.BoundedSemaphore(value=1)
>>> pool_sema.acquire()
True
>>> pool_sema.release()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: semaphore or lock released too many times
...
And the semaphore issue also caused multiprocessing.Queue().put() hung.
(From OE-Core rev: ca1542cdf6b6437a2f3dcdb33ac5216bf841c04a)
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/python')
4 files changed, 166 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python/pass-missing-libraries-to-Extension-for-mul.patch b/meta/recipes-devtools/python/python/pass-missing-libraries-to-Extension-for-mul.patch new file mode 100644 index 0000000000..44fcaacf30 --- /dev/null +++ b/meta/recipes-devtools/python/python/pass-missing-libraries-to-Extension-for-mul.patch | |||
@@ -0,0 +1,82 @@ | |||
1 | From 71447f04979b267f8866573b67a4340b2719d799 Mon Sep 17 00:00:00 2001 | ||
2 | From: Hongxu Jia <hongxu.jia@windriver.com> | ||
3 | Date: Fri, 4 Aug 2017 14:10:43 +0800 | ||
4 | Subject: [PATCH] setup.py: pass missing libraries to Extension for multiprocessing module | ||
5 | |||
6 | In the following commit: | ||
7 | ... | ||
8 | commit e711cafab13efc9c1fe6c5cd75826401445eb585 | ||
9 | Author: Benjamin Peterson <benjamin@python.org> | ||
10 | Date: Wed Jun 11 16:44:04 2008 +0000 | ||
11 | |||
12 | Merged revisions 64104,64117 via svnmerge from | ||
13 | svn+ssh://pythondev@svn.python.org/python/trunk | ||
14 | ... | ||
15 | (see diff in setup.py) | ||
16 | It assigned libraries for multiprocessing module according | ||
17 | the host_platform, but not pass it to Extension. | ||
18 | |||
19 | In glibc, the following commit caused two definition of | ||
20 | sem_getvalue are different. | ||
21 | https://sourceware.org/git/?p=glibc.git;a=commit;h=042e1521c794a945edc43b5bfa7e69ad70420524 | ||
22 | (see diff in nptl/sem_getvalue.c for detail) | ||
23 | `__new_sem_getvalue' is the latest sem_getvalue@@GLIBC_2.1 | ||
24 | and `__old_sem_getvalue' is to compat the old version | ||
25 | sem_getvalue@GLIBC_2.0. | ||
26 | |||
27 | To build python for embedded Linux systems: | ||
28 | http://www.yoctoproject.org/docs/2.3.1/yocto-project-qs/yocto-project-qs.html | ||
29 | If not explicitly link to library pthread (-lpthread), it will | ||
30 | load glibc's sem_getvalue randomly at runtime. | ||
31 | |||
32 | Such as build python on linux x86_64 host and run the python | ||
33 | on linux x86_32 target. If not link library pthread, it caused | ||
34 | multiprocessing bounded semaphore could not work correctly. | ||
35 | ... | ||
36 | >>> import multiprocessing | ||
37 | >>> pool_sema = multiprocessing.BoundedSemaphore(value=1) | ||
38 | >>> pool_sema.acquire() | ||
39 | True | ||
40 | >>> pool_sema.release() | ||
41 | Traceback (most recent call last): | ||
42 | File "<stdin>", line 1, in <module> | ||
43 | ValueError: semaphore or lock released too many times | ||
44 | ... | ||
45 | |||
46 | And the semaphore issue also caused multiprocessing.Queue().put() hung. | ||
47 | |||
48 | Upstream-Status: Submitted [https://github.com/python/cpython/pull/2999] | ||
49 | |||
50 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> | ||
51 | --- | ||
52 | setup.py | 7 +++++-- | ||
53 | 1 file changed, 5 insertions(+), 2 deletions(-) | ||
54 | |||
55 | diff --git a/setup.py b/setup.py | ||
56 | index 54054c2..9646bfc 100644 | ||
57 | --- a/setup.py | ||
58 | +++ b/setup.py | ||
59 | @@ -1586,8 +1586,10 @@ class PyBuildExt(build_ext): | ||
60 | elif host_platform.startswith('netbsd'): | ||
61 | macros = dict() | ||
62 | libraries = [] | ||
63 | - | ||
64 | - else: # Linux and other unices | ||
65 | + elif host_platform.startswith(('linux')): | ||
66 | + macros = dict() | ||
67 | + libraries = ['pthread'] | ||
68 | + else: # Other unices | ||
69 | macros = dict() | ||
70 | libraries = ['rt'] | ||
71 | |||
72 | @@ -1610,6 +1612,7 @@ class PyBuildExt(build_ext): | ||
73 | if sysconfig.get_config_var('WITH_THREAD'): | ||
74 | exts.append ( Extension('_multiprocessing', multiprocessing_srcs, | ||
75 | define_macros=macros.items(), | ||
76 | + libraries=libraries, | ||
77 | include_dirs=["Modules/_multiprocessing"])) | ||
78 | else: | ||
79 | missing.append('_multiprocessing') | ||
80 | -- | ||
81 | 2.7.4 | ||
82 | |||
diff --git a/meta/recipes-devtools/python/python3/pass-missing-libraries-to-Extension-for-mul.patch b/meta/recipes-devtools/python/python3/pass-missing-libraries-to-Extension-for-mul.patch new file mode 100644 index 0000000000..5c3af6b626 --- /dev/null +++ b/meta/recipes-devtools/python/python3/pass-missing-libraries-to-Extension-for-mul.patch | |||
@@ -0,0 +1,82 @@ | |||
1 | From a784b70d47ba2104afbcfd805e2a66cdc2109ec5 Mon Sep 17 00:00:00 2001 | ||
2 | From: Hongxu Jia <hongxu.jia@windriver.com> | ||
3 | Date: Fri, 4 Aug 2017 11:16:14 +0800 | ||
4 | Subject: [PATCH] setup.py: pass missing libraries to Extension for multiprocessing module | ||
5 | |||
6 | In the following commit: | ||
7 | ... | ||
8 | commit e711cafab13efc9c1fe6c5cd75826401445eb585 | ||
9 | Author: Benjamin Peterson <benjamin@python.org> | ||
10 | Date: Wed Jun 11 16:44:04 2008 +0000 | ||
11 | |||
12 | Merged revisions 64104,64117 via svnmerge from | ||
13 | svn+ssh://pythondev@svn.python.org/python/trunk | ||
14 | ... | ||
15 | (see diff in setup.py) | ||
16 | It assigned libraries for multiprocessing module according | ||
17 | the host_platform, but not pass it to Extension. | ||
18 | |||
19 | In glibc, the following commit caused two definition of | ||
20 | sem_getvalue are different. | ||
21 | https://sourceware.org/git/?p=glibc.git;a=commit;h=042e1521c794a945edc43b5bfa7e69ad70420524 | ||
22 | (see diff in nptl/sem_getvalue.c for detail) | ||
23 | `__new_sem_getvalue' is the latest sem_getvalue@@GLIBC_2.1 | ||
24 | and `__old_sem_getvalue' is to compat the old version | ||
25 | sem_getvalue@GLIBC_2.0. | ||
26 | |||
27 | To build python for embedded Linux systems: | ||
28 | http://www.yoctoproject.org/docs/2.3.1/yocto-project-qs/yocto-project-qs.html | ||
29 | If not explicitly link to library pthread (-lpthread), it will | ||
30 | load glibc's sem_getvalue randomly at runtime. | ||
31 | |||
32 | Such as build python on linux x86_64 host and run the python | ||
33 | on linux x86_32 target. If not link library pthread, it caused | ||
34 | multiprocessing bounded semaphore could not work correctly. | ||
35 | ... | ||
36 | >>> import multiprocessing | ||
37 | >>> pool_sema = multiprocessing.BoundedSemaphore(value=1) | ||
38 | >>> pool_sema.acquire() | ||
39 | True | ||
40 | >>> pool_sema.release() | ||
41 | Traceback (most recent call last): | ||
42 | File "<stdin>", line 1, in <module> | ||
43 | ValueError: semaphore or lock released too many times | ||
44 | ... | ||
45 | |||
46 | And the semaphore issue also caused multiprocessing.Queue().put() hung. | ||
47 | |||
48 | Upstream-Status: Submitted [https://github.com/python/cpython/pull/2999] | ||
49 | |||
50 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> | ||
51 | --- | ||
52 | setup.py | 7 +++++-- | ||
53 | 1 file changed, 5 insertions(+), 2 deletions(-) | ||
54 | |||
55 | diff --git a/setup.py b/setup.py | ||
56 | index 4f0f522..d05707d 100644 | ||
57 | --- a/setup.py | ||
58 | +++ b/setup.py | ||
59 | @@ -1606,8 +1606,10 @@ class PyBuildExt(build_ext): | ||
60 | elif host_platform.startswith('netbsd'): | ||
61 | macros = dict() | ||
62 | libraries = [] | ||
63 | - | ||
64 | - else: # Linux and other unices | ||
65 | + elif host_platform.startswith(('linux')): | ||
66 | + macros = dict() | ||
67 | + libraries = ['pthread'] | ||
68 | + else: # Other unices | ||
69 | macros = dict() | ||
70 | libraries = ['rt'] | ||
71 | |||
72 | @@ -1626,6 +1628,7 @@ class PyBuildExt(build_ext): | ||
73 | if sysconfig.get_config_var('WITH_THREAD'): | ||
74 | exts.append ( Extension('_multiprocessing', multiprocessing_srcs, | ||
75 | define_macros=list(macros.items()), | ||
76 | + libraries=libraries, | ||
77 | include_dirs=["Modules/_multiprocessing"])) | ||
78 | else: | ||
79 | missing.append('_multiprocessing') | ||
80 | -- | ||
81 | 2.7.4 | ||
82 | |||
diff --git a/meta/recipes-devtools/python/python3_3.5.3.bb b/meta/recipes-devtools/python/python3_3.5.3.bb index 7419c71515..b67aec9fc0 100644 --- a/meta/recipes-devtools/python/python3_3.5.3.bb +++ b/meta/recipes-devtools/python/python3_3.5.3.bb | |||
@@ -38,6 +38,7 @@ SRC_URI += "\ | |||
38 | file://upstream-random-fixes.patch \ | 38 | file://upstream-random-fixes.patch \ |
39 | file://0001-Issue-21272-Use-_sysconfigdata.py-to-initialize-dist.patch \ | 39 | file://0001-Issue-21272-Use-_sysconfigdata.py-to-initialize-dist.patch \ |
40 | file://Fix-29519-weakref-spewing-exceptions-during-interp-f.patch \ | 40 | file://Fix-29519-weakref-spewing-exceptions-during-interp-f.patch \ |
41 | file://pass-missing-libraries-to-Extension-for-mul.patch \ | ||
41 | " | 42 | " |
42 | SRC_URI[md5sum] = "57d1f8bfbabf4f2500273fb0706e6f21" | 43 | SRC_URI[md5sum] = "57d1f8bfbabf4f2500273fb0706e6f21" |
43 | SRC_URI[sha256sum] = "eefe2ad6575855423ab630f5b51a8ef6e5556f774584c06beab4926f930ddbb0" | 44 | SRC_URI[sha256sum] = "eefe2ad6575855423ab630f5b51a8ef6e5556f774584c06beab4926f930ddbb0" |
diff --git a/meta/recipes-devtools/python/python_2.7.13.bb b/meta/recipes-devtools/python/python_2.7.13.bb index 4ef99523e0..98bc8ada8b 100644 --- a/meta/recipes-devtools/python/python_2.7.13.bb +++ b/meta/recipes-devtools/python/python_2.7.13.bb | |||
@@ -27,6 +27,7 @@ SRC_URI += "\ | |||
27 | file://use_sysroot_ncurses_instead_of_host.patch \ | 27 | file://use_sysroot_ncurses_instead_of_host.patch \ |
28 | file://add-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch \ | 28 | file://add-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch \ |
29 | file://Don-t-use-getentropy-on-Linux.patch \ | 29 | file://Don-t-use-getentropy-on-Linux.patch \ |
30 | file://pass-missing-libraries-to-Extension-for-mul.patch \ | ||
30 | " | 31 | " |
31 | 32 | ||
32 | S = "${WORKDIR}/Python-${PV}" | 33 | S = "${WORKDIR}/Python-${PV}" |