Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit bf999a2

Browse files
committed
Add various patches used for this build of the installer.
1 parent cfa9887 commit bf999a2

6 files changed

+405
-0
lines changed

CHANGES.md

+13
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ Changelog for the Windows Installer
1111
about making new releases. So we add the ability to include post-release
1212
patches as needed.
1313

14+
* Added patch for giac to prevent possible hang in the Sage-Giac interface
15+
(https://trac.sagemath.org/ticket/27385).
16+
17+
* Added several patches for stability in OpenBLAS. Note, however, that
18+
the current release does not use OpenBLAS, but rather just uses
19+
Cygwin's default BLAS. A future release will switch to OpenBLAS for
20+
likely performance gains (https://trac.sagemath.org/ticket/27493
21+
https://trac.sagemath.org/ticket/27509
22+
https://trac.sagemath.org/ticket/27565).
23+
24+
* Added patch needed for psutil to work with Cygwin 3.0 on which this
25+
build is based (https://trac.sagemath.org/ticket/27702).
26+
1427

1528
0.4.2 (2019-02-11)
1629
------------------
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
From 8d0a9df87cfe93082085f2805e47ef75026588a3 Mon Sep 17 00:00:00 2001
2+
From: "Erik M. Bray" <[email protected]>
3+
Date: Wed, 6 Mar 2019 15:52:01 +0100
4+
Subject: [PATCH] Trac #27385: Patch for Cygwin to re-disable threaded eval
5+
until/unless it can be fixed.
6+
7+
---
8+
build/pkgs/giac/package-version.txt | 2 +-
9+
build/pkgs/giac/patches/cygwin-icas.patch | 23 +++++++++++++++++++++++
10+
2 files changed, 24 insertions(+), 1 deletion(-)
11+
create mode 100644 build/pkgs/giac/patches/cygwin-icas.patch
12+
13+
diff --git a/build/pkgs/giac/package-version.txt b/build/pkgs/giac/package-version.txt
14+
index ce3c8deec6..b894ff7476 100644
15+
--- a/build/pkgs/giac/package-version.txt
16+
+++ b/build/pkgs/giac/package-version.txt
17+
@@ -1 +1 @@
18+
-1.5.0.37.p0
19+
+1.5.0.37.p1
20+
diff --git a/build/pkgs/giac/patches/cygwin-icas.patch b/build/pkgs/giac/patches/cygwin-icas.patch
21+
new file mode 100644
22+
index 0000000000..8866980664
23+
--- /dev/null
24+
+++ b/build/pkgs/giac/patches/cygwin-icas.patch
25+
@@ -0,0 +1,23 @@
26+
+Disable threaded eval function on Cygwin since it's currently
27+
+buggy, and not strictly needed in the first place since we don't
28+
+build giac with FLTK support; see https://trac.sagemath.org/ticket/27385
29+
+--- a/src/icas.cc 2018-12-22 17:08:24.000000000 +0100
30+
++++ b/src/icas.cc 2019-03-06 14:38:19.814030200 +0100
31+
+@@ -160,7 +160,7 @@
32+
+ using namespace giac;
33+
+ #define STDIN_FILENO 0
34+
+ namespace xcas {
35+
+- /*
36+
++#ifdef __CYGWIN__
37+
+ void icas_eval(giac::gen & g,giac::gen & gg,int & reading_file,std::string &filename,giac::context * contextptr){
38+
+ gg=protecteval(g,10,contextptr);
39+
+ }
40+
+@@ -168,7 +168,7 @@
41+
+ bool fltk_view(const giac::gen & g,giac::gen & ge,const std::string & filename,std::string & figure_filename,int file_type,const giac::context *contextptr){
42+
+ return false;
43+
+ }
44+
+- */
45+
++#endif
46+
+ }
47+
+
48+
+ #else
49+
--
50+
2.15.1
51+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
From abe0d276b890bc1005158ad39011443b62d55296 Mon Sep 17 00:00:00 2001
2+
From: "Erik M. Bray" <[email protected]>
3+
Date: Fri, 15 Mar 2019 15:37:56 +0100
4+
Subject: [PATCH] Trac #27493: Patch OpenBLAS to read environment variables
5+
properly on Cygwin
6+
7+
---
8+
.../patches/0001-Use-POSIX-getenv-on-Cygwin.patch | 28 ++++++++++++++++++++++
9+
1 file changed, 28 insertions(+)
10+
create mode 100644 build/pkgs/openblas/patches/0001-Use-POSIX-getenv-on-Cygwin.patch
11+
12+
diff --git a/build/pkgs/openblas/patches/0001-Use-POSIX-getenv-on-Cygwin.patch b/build/pkgs/openblas/patches/0001-Use-POSIX-getenv-on-Cygwin.patch
13+
new file mode 100644
14+
index 0000000000..3a26960a9f
15+
--- /dev/null
16+
+++ b/build/pkgs/openblas/patches/0001-Use-POSIX-getenv-on-Cygwin.patch
17+
@@ -0,0 +1,28 @@
18+
+From 1006ff8a7bc4ee77150d6f13483838c96789e3fc Mon Sep 17 00:00:00 2001
19+
+From: "Erik M. Bray" <[email protected]>
20+
+Date: Fri, 15 Mar 2019 15:06:30 +0100
21+
+Subject: [PATCH] Use POSIX getenv on Cygwin
22+
+
23+
+The Windows-native GetEnvironmentVariable cannot be relied on, as
24+
+Cygwin does not always copy environment variables set through Cygwin
25+
+to the Windows environment block, particularly after fork().
26+
+---
27+
+ common.h | 2 +-
28+
+ 1 file changed, 1 insertion(+), 1 deletion(-)
29+
+
30+
+diff --git a/common.h b/common.h
31+
+index 7fcd5e31..f239c3d7 100644
32+
+--- a/common.h
33+
++++ b/common.h
34+
+@@ -439,7 +439,7 @@ please https://github.com/xianyi/OpenBLAS/issues/246
35+
+ typedef char env_var_t[MAX_PATH];
36+
+ #define readenv(p, n) 0
37+
+ #else
38+
+-#ifdef OS_WINDOWS
39+
++#if defined(OS_WINDOWS) && !defined(OS_CYGWIN_NT)
40+
+ typedef char env_var_t[MAX_PATH];
41+
+ #define readenv(p, n) GetEnvironmentVariable((LPCTSTR)(n), (LPTSTR)(p), sizeof(p))
42+
+ #else
43+
+--
44+
+2.15.1
45+
+
46+
--
47+
2.15.1
48+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
From ee6e4a3eb09aebc2ed9fe7959c4f997b5e75664f Mon Sep 17 00:00:00 2001
2+
From: "Erik M. Bray" <[email protected]>
3+
Date: Tue, 19 Mar 2019 16:34:15 +0100
4+
Subject: [PATCH] Trac #27509: Add patch from upstream pull request to fix
5+
memory leak on Cygwin
6+
7+
---
8+
build/pkgs/openblas/patches/2064.patch | 137 +++++++++++++++++++++++++++++++++
9+
1 file changed, 137 insertions(+)
10+
create mode 100644 build/pkgs/openblas/patches/2064.patch
11+
12+
diff --git a/build/pkgs/openblas/patches/2064.patch b/build/pkgs/openblas/patches/2064.patch
13+
new file mode 100644
14+
index 0000000000..399277a00e
15+
--- /dev/null
16+
+++ b/build/pkgs/openblas/patches/2064.patch
17+
@@ -0,0 +1,137 @@
18+
+Fixes memory leak in Cygwin that occurs when repeatedly shutting down
19+
+and re-intializing the the thread pool, e.g. when forking the process.
20+
+See https://trac.sagemath.org/ticket/27509
21+
+
22+
+From 4ad694eda1ff79040778648d44cda5b8f774c38d Mon Sep 17 00:00:00 2001
23+
+From: "Erik M. Bray" <[email protected]>
24+
+Date: Mon, 18 Mar 2019 20:32:48 +0100
25+
+Subject: [PATCH 1/2] Fix for #2063: The DllMain used in Cygwin did not run the
26+
+ thread memory pool cleanup upon THREAD_DETACH which is needed when compiled
27+
+ with USE_TLS=1.
28+
+
29+
+---
30+
+ driver/others/memory.c | 11 +++++++++--
31+
+ exports/dllinit.c | 24 +++++++++++++++++-------
32+
+ 2 files changed, 26 insertions(+), 9 deletions(-)
33+
+
34+
+diff --git a/driver/others/memory.c b/driver/others/memory.c
35+
+index ed407a858..ac8545f35 100644
36+
+--- a/driver/others/memory.c
37+
++++ b/driver/others/memory.c
38+
+@@ -1313,6 +1313,13 @@ void blas_memory_free_nolock(void * map_address) {
39+
+ free(map_address);
40+
+ }
41+
+
42+
++#ifdef SMP
43+
++void blas_thread_memory_cleanup(void) {
44+
++ blas_memory_cleanup((void*)get_memory_table());
45+
++}
46+
++#endif
47+
++
48+
++
49+
+ void blas_shutdown(void){
50+
+ #ifdef SMP
51+
+ BLASFUNC(blas_thread_shutdown)();
52+
+@@ -1322,7 +1329,7 @@ void blas_shutdown(void){
53+
+ /* Only cleanupIf we were built for threading and TLS was initialized */
54+
+ if (local_storage_key)
55+
+ #endif
56+
+- blas_memory_cleanup((void*)get_memory_table());
57+
++ blas_thread_memory_cleanup();
58+
+
59+
+ #ifdef SEEK_ADDRESS
60+
+ base_address = 0UL;
61+
+@@ -1552,7 +1559,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser
62+
+ break;
63+
+ case DLL_THREAD_DETACH:
64+
+ #if defined(SMP)
65+
+- blas_memory_cleanup((void*)get_memory_table());
66+
++ blas_thread_memory_cleanup();
67+
+ #endif
68+
+ break;
69+
+ case DLL_PROCESS_DETACH:
70+
+diff --git a/exports/dllinit.c b/exports/dllinit.c
71+
+index 02ff092e9..0e1bb34e3 100644
72+
+--- a/exports/dllinit.c
73+
++++ b/exports/dllinit.c
74+
+@@ -40,15 +40,25 @@
75+
+
76+
+ void gotoblas_init(void);
77+
+ void gotoblas_quit(void);
78+
++#if defined(SMP) && defined(USE_TLS)
79+
++void blas_thread_memory_cleanup(void);
80+
++#endif
81+
+
82+
+ BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved) {
83+
+-
84+
+- if (reason == DLL_PROCESS_ATTACH) {
85+
+- gotoblas_init();
86+
+- }
87+
+-
88+
+- if (reason == DLL_PROCESS_DETACH) {
89+
+- gotoblas_quit();
90+
++ switch(reason) {
91+
++ case DLL_PROCESS_ATTACH:
92+
++ gotoblas_init();
93+
++ break;
94+
++ case DLL_PROCESS_DETACH:
95+
++ gotoblas_quit();
96+
++ break;
97+
++ case DLL_THREAD_ATTACH:
98+
++ break;
99+
++ case DLL_THREAD_DETACH:
100+
++#if defined(SMP) && defined(USE_TLS)
101+
++ blas_thread_memory_cleanup(void);
102+
++#endif
103+
++ break;
104+
+ }
105+
+
106+
+ return TRUE;
107+
+
108+
+From 8ba9e2a61a1cf34e9b2efc5af61f5ebaaf6ab902 Mon Sep 17 00:00:00 2001
109+
+From: "Erik M. Bray" <[email protected]>
110+
+Date: Tue, 19 Mar 2019 10:22:02 +0100
111+
+Subject: [PATCH 2/2] Also call CloseHandle on each thread, as well as on the
112+
+ event so as to not leak thread handles.
113+
+
114+
+---
115+
+ driver/others/blas_server_win32.c | 5 +++++
116+
+ exports/dllinit.c | 2 +-
117+
+ 2 files changed, 6 insertions(+), 1 deletion(-)
118+
+
119+
+diff --git a/driver/others/blas_server_win32.c b/driver/others/blas_server_win32.c
120+
+index bae344c59..0b38ee365 100644
121+
+--- a/driver/others/blas_server_win32.c
122+
++++ b/driver/others/blas_server_win32.c
123+
+@@ -461,13 +461,18 @@ int BLASFUNC(blas_thread_shutdown)(void){
124+
+ SetEvent(pool.killed);
125+
+
126+
+ for(i = 0; i < blas_num_threads - 1; i++){
127+
++ // Could also just use WaitForMultipleObjects
128+
+ WaitForSingleObject(blas_threads[i], 5); //INFINITE);
129+
+ #ifndef OS_WINDOWSSTORE
130+
+ // TerminateThread is only available with WINAPI_DESKTOP and WINAPI_SYSTEM not WINAPI_APP in UWP
131+
+ TerminateThread(blas_threads[i],0);
132+
+ #endif
133+
++ CloseHandle(blas_threads[i]);
134+
+ }
135+
+
136+
++ CloseHandle(pool.filled);
137+
++ CloseHandle(pool.killed);
138+
++
139+
+ blas_server_avail = 0;
140+
+ }
141+
+
142+
+diff --git a/exports/dllinit.c b/exports/dllinit.c
143+
+index 0e1bb34e3..4a05c0e14 100644
144+
+--- a/exports/dllinit.c
145+
++++ b/exports/dllinit.c
146+
+@@ -56,7 +56,7 @@ BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved) {
147+
+ break;
148+
+ case DLL_THREAD_DETACH:
149+
+ #if defined(SMP) && defined(USE_TLS)
150+
+- blas_thread_memory_cleanup(void);
151+
++ blas_thread_memory_cleanup();
152+
+ #endif
153+
+ break;
154+
+ }
155+
--
156+
2.15.1
157+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
From 3d0a86bebe0233d277c60a315ea82ed5a3a0f24f Mon Sep 17 00:00:00 2001
2+
From: "Erik M. Bray" <[email protected]>
3+
Date: Mon, 1 Apr 2019 11:35:38 +0200
4+
Subject: [PATCH] Trac #27565: Add patch from upstream to fix segfaults.
5+
6+
---
7+
build/pkgs/openblas/package-version.txt | 2 +-
8+
...03-Move-TLS-key-deletion-to-openblas_quit.patch | 50 ++++++++++++++++++++++
9+
2 files changed, 51 insertions(+), 1 deletion(-)
10+
create mode 100644 build/pkgs/openblas/patches/0003-Move-TLS-key-deletion-to-openblas_quit.patch
11+
12+
diff --git a/build/pkgs/openblas/package-version.txt b/build/pkgs/openblas/package-version.txt
13+
index f5447be62e..faa2471518 100644
14+
--- a/build/pkgs/openblas/package-version.txt
15+
+++ b/build/pkgs/openblas/package-version.txt
16+
@@ -1 +1 @@
17+
-0.3.5.p0
18+
+0.3.5.p1
19+
diff --git a/build/pkgs/openblas/patches/0003-Move-TLS-key-deletion-to-openblas_quit.patch b/build/pkgs/openblas/patches/0003-Move-TLS-key-deletion-to-openblas_quit.patch
20+
new file mode 100644
21+
index 0000000000..6984c83e56
22+
--- /dev/null
23+
+++ b/build/pkgs/openblas/patches/0003-Move-TLS-key-deletion-to-openblas_quit.patch
24+
@@ -0,0 +1,50 @@
25+
+Fixes incorrect releasing of TLS variable keys, resulting in possible
26+
+segfaults / crashes. Fix from https://github.com/xianyi/OpenBLAS/pull/1957
27+
+added in https://trac.sagemath.org/ticket/27565
28+
+This patch can be removed upon a future update to an OpenBLAS which
29+
+includes it.
30+
+
31+
+From ad2c386d6ad99d3021e33cbbfb311150b2586c93 Mon Sep 17 00:00:00 2001
32+
+From: Martin Kroeker <[email protected]>
33+
+Date: Thu, 10 Jan 2019 00:32:50 +0100
34+
+Subject: [PATCH] Move TLS key deletion to openblas_quit
35+
+
36+
+fixes #1954 (as suggested by thrasibule in that issue)
37+
+---
38+
+ driver/others/memory.c | 13 ++++++++-----
39+
+ 1 file changed, 8 insertions(+), 5 deletions(-)
40+
+
41+
+diff --git a/driver/others/memory.c b/driver/others/memory.c
42+
+index 6f7a7db8..72d3e173 100644
43+
+--- a/driver/others/memory.c
44+
++++ b/driver/others/memory.c
45+
+@@ -1073,11 +1073,6 @@ static volatile int memory_initialized = 0;
46+
+ }
47+
+ free(table);
48+
+ }
49+
+-#if defined(OS_WINDOWS)
50+
+- TlsFree(local_storage_key);
51+
+-#else
52+
+- pthread_key_delete(local_storage_key);
53+
+-#endif
54+
+ }
55+
+
56+
+ static void blas_memory_init(){
57+
+@@ -1491,6 +1486,14 @@ void DESTRUCTOR gotoblas_quit(void) {
58+
+
59+
+ blas_shutdown();
60+
+
61+
++#if defined(SMP)
62+
++#if defined(OS_WINDOWS)
63+
++ TlsFree(local_storage_key);
64+
++#else
65+
++ pthread_key_delete(local_storage_key);
66+
++#endif
67+
++#endif
68+
++
69+
+ #ifdef PROFILE
70+
+ moncontrol (0);
71+
+ #endif
72+
+--
73+
+2.15.1
74+
+
75+
--
76+
2.15.1
77+

0 commit comments

Comments
 (0)